The MU forums have moved to WordPress.org

Top bar (52 posts)

  1. daniminas
    Member
    Posted 15 years ago #

    Hi, i need to put a top navigation bar in all the blogs (like blogger it does). I been reading, some functions, but i don't know where tu put or register it..

    Thanks in advance

  2. kahless
    Member
    Posted 15 years ago #

    Check this thread. It tells you how to get it to show at the top without having to edit every theme. It doesn't tell you how to get the functionality, that's up to you.

  3. drmike
    Member
    Posted 15 years ago #

    There is also a plugin as well, which is mentioned in that thread but you have to manually add it into each theme.

  4. suleiman
    Member
    Posted 15 years ago #

    daniminas, you should be made aware that the mu-admin bar plugin, as great as it is, does not incorporate the "navigation" links from one blog to the next as on Blogger.com. I've been asking for this feature for a while so if you yourself know any php or have friends that do, this is a worthy cause :)

  5. drmike
    Member
    Posted 15 years ago #

    *cough*

    :)

  6. suleiman
    Member
    Posted 15 years ago #

    thanks a ton drmike...i'm going to work on getting this integrated as we speak :)

  7. drmike
    Member
    Posted 15 years ago #

    Actually it's fairly easy to add in to your admin bar:

    # Login and logout link.
    echo "nt<li><a href=\"http://daria.be/next.php\">Next Blog</a></li>";
    echo "nt<li><a href=\"http://daria.be/forums/\">Support Forums</a></li>";
    echo "nt<li>"; wp_loginout(); echo "</li>";
    echo "n</ul></div>";

    Drop next.php into your root.

  8. kahless
    Member
    Posted 15 years ago #

    Mike can I incorporate this in MU Admin Bar?

  9. kahless
    Member
    Posted 15 years ago #

    Mike the resolution in the thread makes it so you DON'T have to add code to every template. We cheat and use do_action('wp_footer') with a fixed position for the bar to make it show at the top. We can't use do_action('wp_header') because most themes seem to have this before the body tag. I would propose a wp_body hook be added to WP and hence WPMU so that things like the admin bar wouldn't have to cheat to work like we want.

  10. kahless
    Member
    Posted 15 years ago #

    Mike I can't seem to get it to work I keep getting the blog I was on and the address has
    %3C?php%20echo%20$randomblog;%20?%3E Any thoughts?

  11. suleiman
    Member
    Posted 15 years ago #

    yepp, I get the same error as kahless. Pressing the Next Blog button points the browser to a 404 page on the main home blog.

    EDIT: I got it working! Bizzare problem really, but when I opened up next.php in dreamweaver I noticed some odd symbols before the < ? php tag on the first line. Kahless try checking your file to see if it works.

    Thanks again dr.mike! Been looking for this one!

  12. zeug
    Member
    Posted 15 years ago #

    same here, the next.php file was utf 16-little endian which went crazy with illegal invisible characters when I uploaded it, so I changed the text file format to utf 8, uploaded again and no problems, works like a charm.

  13. drmike
    Member
    Posted 15 years ago #

    Hmmm... Shouldn't be any illegal characters at the front of the file. It's one of the reasons why I use Ultraedit because it doesn't put crud in there like wordpad does in rtf mode.

  14. kahless
    Member
    Posted 15 years ago #

    suleiman and zeug,

    Yep mine was UTF 16 (Little Endian) changing to UTF 8 fixed it.

    Mike would you mind if I package this with the Admin bar or would you rather I put in the code and comment it and point people to the random blog plugin?

  15. drmike
    Member
    Posted 15 years ago #

    You can put them together. :)

    I'd actually like to see the WP.com code now for the next blog link to see how they did it. There's got to be a better way than doing an array every time the link is clicked on.

  16. kahless
    Member
    Posted 15 years ago #

    I updated MU Admin Bar on wpmudev with support for Random Blog but did not include Random Blog in the download. It also contains the page correction by Mike and his styling changes. Anyone else with projects on wpmudev unable to manage their files? I got

    WordPress database error: [Unknown column 'project_ID' in 'where clause']
    SELECT ID, name, downloads FROM files WHERE project_ID = '21' ORDER BY ID DESC LIMIT 0, 30

    when trying to delete the old version.

  17. drmike
    Member
    Posted 15 years ago #

    I get the occasional error myself but it worked well enough to get a file up there.

  18. andrea_r
    Moderator
    Posted 15 years ago #

    "I'd actually like to see the WP.com code now for the next blog link to see how they did it."
    Is there any way to grab the current blog's ID? Snag that, if possible and increment or skip around.

  19. drmike
    Member
    Posted 15 years ago #

    Yup, it's in $blog_id. Should be a global variable.

    Staff has admited though that it's a random blog routine. If you clikc once on Next over there, next time it will be a different blog.

  20. suleiman
    Member
    Posted 15 years ago #

    is the admin bar supposed to display only when a user is logged in?

    The problem I am having is when a user is logged into their blog and click on "Next Blog" then it takes them to a different blog that doesn't have the admin bar. So in essence they can only navigate to one more blog from their own and that's it.

    Is there a way to setup the admin bar so that it checks if the user is logged in and then provides access to the dashboard functions, but otherwise still displays the "Next Blog" and "Support Forums" links?

  21. drmike
    Member
    Posted 15 years ago #

    then it takes them to a different blog that doesn't have the admin bar.

    hmmm, I never noticed that be sul is right. It isn't there.

    Probably could buy just doing a check to see if the blog they are looking at is theirs and, if its not, then just skip the array.

    Please send me an email to support ( at ) daria ( dot ) be and I'll see if i can hack something together.

  22. suleiman
    Member
    Posted 15 years ago #

    e-mail sent drmike

  23. kahless
    Member
    Posted 15 years ago #

    Mike,

    Something changed because I swear the admin bar showed on all blogs at one point if a user was logged in. But now it only shows if you are the owner or site admin. This is correct behavior based on the code. What if we add

    else {
    # Login and logout link.

    /* echo "nt<li><a href="$url/next.php">Next Blog</a></li>"; */ /* uncomment if you are using dr mike's random blog plugin */
    echo "nt<li>"; wp_loginout(); echo "</li>";
    echo "n</ul></div>";
    }

    at the end of the if ( current_user_can('read') ) code and comment out the lines in function wp_admin_bar_style () that cause the CSS only to be loaded for a logged in user?

    This should cause the admin bar to be displayed for everyone. If you are not a user then you possibly get Next Blog and Login, if you are a logged in user you get a greeting and possibly Next Blog and Logout, if you are the admin you also get the Dashboard links, and if you are the Site Admin you also get a link to the Admin area.

  24. kahless
    Member
    Posted 15 years ago #

    OK, I think I have this working. Check http://blogs.breitenbucher.net/ and see if this is on the right track. This site is hosted on DreamHost and they are having some issues with their network. I can access the site now but they are still worming to correct their problems.

    My little trick to get the URL of the main site from the db and not having to hard code it doesn't work for the admin bar of users who are not logged in so I had to hard code it for this new bit of code.

  25. suleiman
    Member
    Posted 15 years ago #

    kahless, I tried this out on my wpmu install and it does display the links in the proper location (at least in firefox, camino, etc.,) but I can't figure out what code to comment out to get the styling to appear when a user is not logged in.

    When I go to comment out:

    global $user_level;

    if ( isset($user_level) ) { // only add style if user logged in.
    ob_start();

    ?>

    Then the page doesn't load. No errors. Just no load.

  26. kahless
    Member
    Posted 15 years ago #

    suleiman,

    Add

    else {
    # Login and logout link.
    echo '<div id="wp-admin-bar"><ul>';
    echo "nt<li><a href="http://domain.tld/next.php">Next Blog</a></li>"; /* uncomment if you are using dr mike's random blog plugin */
    echo "nt<li>"; wp_loginout(); echo "</li>";
    echo "n</ul></div>";
    }

    right before

    }

    function wp_admin_bar_style () {

    Comment if ( isset($user_level) ) in the wp_admin_bar_style and the } right after print($css); at the end of wp_admin_bar_style. In the little else code above you should be able to add whatever links you want and this will get the blogger functionality many people have been asking for.

  27. suleiman
    Member
    Posted 15 years ago #

    It worked! Thanks a ton for this kahless, it's working great.

    Now I wish I could just move the text so it was in the middle or the left of the admin bar.

  28. kahless
    Member
    Posted 15 years ago #

    Simple. In the new else statement edit echo '<div id="wp-admin-bar"><ul>' to say echo '<div id="wp-admin-bar-not-logged"><ul>'. In the CSS section replace the stuff after the body element and before /* ]]> */ with

    #wp-admin-bar-not-logged {
    position: relative;
    z-index: 66;
    height: 28px; /* changed by dr mike */
    margin: 0;
    padding: 2px;
    background: #f9f9f9;
    border: 1px solid #666;
    border-bottom:1px solid #3285ae;
    font:12px "Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana; /* added by dr mike */
    color: #fff; /* changed by dr mike */
    clear: both;
    text-align: center;
    background:url('/wp-includes/images/adminbar.png') #14568a no-repeat 50% 0; /* added by dr mike */
    }

    #wp-admin-bar, #wp-admin-bar-not-logged { /* part of hack to make the bar show at the top of all templates */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    }

    #wp-admin-bar ul, #wp-admin-bar-not-logged ul {
    margin: 0;
    padding: 0;
    list-style-type: none;
    }

    #wp-admin-bar ul li, #wp-admin-bar-not-logged ul li {
    list-style-type: none;
    display: inline;
    margin: 0 10px;
    padding: 0;
    font:12px "Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana; /* added by dr mike */
    color: #fff; /* changed by dr mike */
    }

    #wp-admin-bar ul li.login, #wp-admin-bar-not-logged ul li.login { margin-right: 30px; }
    #wp-admin-bar strong, #wp-admin-bar-not-logged strong { font-weight: bold; }
    #wp-admin-bar a, #wp-admin-bar-not-logged a { color: #fff; }
    #wp-admin-bar a:hover, #wp-admin-bar-not-logged a:hover { color: #488cff; }

  29. suleiman
    Member
    Posted 15 years ago #

    thanks for the tip kahless, actually what I was trying to do was have some content be on hte left and some on the right while the user is not logged in.

    I wanted the "Home" and "Signup Now!" links to appear on the left, while the "Next Blog" link appeared on its own on the right. I've been trying to add some classes to the built-in css, but it's not really my forte.

  30. kahless
    Member
    Posted 15 years ago #

    I'll post something tomorrow.

About this Topic