The MU forums have moved to WordPress.org

Solved: Dashboard Drop Down menu (42 posts)

  1. drmike
    Member
    Posted 17 years ago #

    Step #1:

    Modify wp-admin/wp-admin.css and find the bit for 'wphead h1 span'

    - Change the span to #viewsite and add in margin-left: 10px;

    - Add in the following:

    #switchermenu a {
    font-size: 20px;
    padding: 0 1.5em 0 10px;
    display: block;
    color: #c3def1;
    }
    #switchermenu a:hover {
    background: #1a70b4;
    color: #fff;
    }
    #switchermenu li {
    margin: 0;
    padding: 0;
    }
    #switchermenu {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border-top: 1px solid #1a70b4;
    border-left: 1px solid #1a70b4;
    position: absolute;
    left: 0;
    top: 1em;
    background: #14568a;
    z-index: 1;
    }

  2. drmike
    Member
    Posted 17 years ago #

    Step #2:

    Grab a copy of the drop down menu arrow thing:

    http://s.wordpress.com/i/bullet_arrow_down.gif

    And upload it to your wp-admin/images directory.

    Make note of the URL for later.

  3. drmike
    Member
    Posted 17 years ago #

    Step #3:

    Open up wp-admin/admin-header.php and place the following code in right before the closing head line. Note the URL that needs to be places for the drop down arrow.

    (Let's see if it works)

    <script type="text/javascript">
    jQuery( function($) {
    var switchTime;
    var w = false;
    var h = $( '#blog-title' )
    	.css({
    		background: 'transparent url(URL to the arrow image here) no-repeat scroll 100% .2em;',
    		padding: '0 25px 2px 5px',
    		cursor: 'pointer',
    		border: '1px solid #14568a'
    	})
    	.parent().css( { position: 'relative' }).end()
    	.append( $('#switchermenu') )
    	.hover( function() {
    		$(this).css({ border: '1px solid #1a70b4'});
    		switchTime = window.setTimeout( function() {
    			$('#switchermenu').fadeIn('fast').css( 'top', h ).find('a').width( w = w ? w : $('#switchermenu').width() );
    		}, 300 );
    	}, function() {
    		window.clearTimeout( switchTime );
    		$(this).css({ border: '1px solid #14568a' }) ;
    		$('#switchermenu').hide();
    	})
    	.height() - 3;
    });
    </script>
  4. drmike
    Member
    Posted 17 years ago #

    Step #4:

    Drop down a couple of lines to the h1 bit where it lists the title of the blog and replace it with the following:

    <h1><span id="blog-title"><?php echo wptexturize(get_bloginfo(('name'))); ?></span>
    <span id="viewsite">(<a href="<?php echo get_option('home') . '/'; ?>"><?php _e('View site &raquo;') ?></a>)</span>
    </h1>
  5. drmike
    Member
    Posted 17 years ago #

    Step #5:

    Here's the code. Add it in after the closing h1 from Step #4Let me post it and then I'll explain it:

    <ul id="switchermenu"  style="display: none;">
    <?php
    	$blogs = get_blogs_of_user($current_user->ID);
    	if ( ! empty($blogs) ) foreach ( $blogs as $blog ) {
    
    $tmpblogname = $blog->domain . $blog->path;
    $tmpblogname = str_replace("Replace Me", "", $tmpblogname);
    
    echo "<li><a href='http://" . $blog->domain . $blog->path . "wp-admin/'>" . $tmpblogname . "</a></li>n";
            }
    ?>
  6. drmike
    Member
    Posted 17 years ago #

    See that "Replace Me" in there? Without it and the line before it, the code would just display the entire URL of your blog. You need to put in there bit from the URL that every blog has. It depends on though if you're using subdomains or sundirectories though.

    Using my domain as an example:

    For subdomains, replace it with the following:

    .daria.be/

    For subdomains, replace it with the following:

    daria.be/

    Hope this helps,
    -drmike

  7. drmike
    Member
    Posted 17 years ago #

    Found a small issue. The menu doesn't appear on all pages. WPMu doesn't load the jQuery javascripts every page. Just got to figure out where the hook is for this. Hold on...

  8. demonicume
    Member
    Posted 17 years ago #

    really cool. cant wait to get home and try it.

  9. frozonecold
    Member
    Posted 17 years ago #

    Hey Dr.Mike could you post some screenshots? Some of us would like to see it before they install it.

  10. drmike
    Member
    Posted 17 years ago #

    It's the same as wp.com but I will in a second.

    The fix for teh issue I had above is to open up wp-admin/admin-header.php and place the following right above the get_admin_page_title(); line

    wp_enqueue_script('interface');

  11. drmike
    Member
    Posted 17 years ago #

    Posted about it

  12. frozonecold
    Member
    Posted 17 years ago #

    Thank you Dr.Mike. I didn't realize that it was an exact copy. You know what would be a good idea though.... Making the sub-pages on the admin have drop down menu's as well.

  13. drmike
    Member
    Posted 17 years ago #

    It's not an exact copy to my knowledge. While the CSS is, the coding from step #5 is my own. (In theory at least.)

  14. hempsworth
    Member
    Posted 17 years ago #

    This is great, thanks!

    But there is a typo in the code you posted:

    echo "<li><a href='http://" . $blog->domain . $blog->path . "wp-admin/'>" . $tmpblogname . "</a></li>n";

    There is an n after

    </a></li>

    Also, how could I make it display the blog name rather than the path?

  15. demonicume
    Member
    Posted 17 years ago #

    hrm.. nothing happened. no error messge. nothing is broken. checked in IE7 and FF. i'm missing something and i cant figure out what it is. ok. be back!

  16. drmike
    Member
    Posted 17 years ago #

    There's supposed to be a slash in there before the n

    \ n

    It's a line feed in the outputted html.

    Sorry about that. I had forgotten that the forum software strips it out.

  17. hempsworth
    Member
    Posted 17 years ago #

    Sorted!

    Any luck on getting it to display the name of the blog in the list instead of "path/" ?

  18. demonicume
    Member
    Posted 17 years ago #

    would the \ n break it?

  19. hempsworth
    Member
    Posted 17 years ago #

    It's working great for me, but I'm not sure what the \n is for to be honest, it seemed to work the same without it.

  20. drmike
    Member
    Posted 17 years ago #

    Hemp, that's an advanced feature ;)

    You probably could. I only went this far as it's what wp.com does. If there was someway to get get_blogs_of_user($current_user->ID) to return the blog_id and then used that to pull the name out of the db, you could probably do it.

    My concern is these folks with mile long blog names.

    All the \n does is make a line break in the outputted code. Else everything runs into a single line.

  21. demonicume
    Member
    Posted 17 years ago #

    still unsure why its not working. *grumble* only thing thats chaged in the size od the words 'viewsite'

  22. drmike
    Member
    Posted 17 years ago #

    wphead h1 #viewsite

    Sorry about that.

  23. hempsworth
    Member
    Posted 17 years ago #

    Where is

    $blog->domain

    comming from? An obvious idea would be

    $blog->name

    or something similar. Though I'm sure you though of that already :P

    Could be parsed somehow, adding "..." to the end so you get "Somereallylong..."? Shouldn't be hard to do, I'v seen it done in many recent comments widgets and things like that.

  24. demonicume
    Member
    Posted 17 years ago #

    hempsworth - can i get a look at your admin-header.php. i've gone over this again and again, it just aint working.

  25. drmike
    Member
    Posted 17 years ago #

    $blog->domain comes out of the get_current_blogs_of_users function.

    I can submit a patch to trac if needbe. It'll be tomorrow though. It's on the to-do list

    http://www.rememberthemilk.com/home/mike.wendell/1157760/

  26. demonicume
    Member
    Posted 17 years ago #

    thanks a lot, Doc

  27. hempsworth
    Member
    Posted 17 years ago #

    I think it would certainly improve it. Sounds like a good idea.

    demonicume - Mine is modified so probably not the best example! If you post yours we can find out what is going wrong :) Did you make the css change that drmike posted by any chance?

    wphead h1 #viewsite
  28. frozonecold
    Member
    Posted 17 years ago #

    Hey doc why don't you do the same for the admin sub-categories?

  29. drmike
    Member
    Posted 17 years ago #

    Not a clue as to what you're talking about. There's nothing here about categories. Are you sure you've got the right thread?

  30. frozonecold
    Member
    Posted 17 years ago #

    Im on the right thread... I just cant word anything right. What I am trying to say is that you should use the drop down menu for other parts of the admin interface such as the admin pages (post, manage, presentation...). Is it clear now

About this Topic