The MU forums have moved to WordPress.org

blogs sort order (27 posts)

  1. billjones
    Member
    Posted 14 years ago #

    2.8.1

    Wordpress MU..

    I use get blog option to list the blogs in a MU install, I really want to have them listed alphabetically by NAME, now it lists by last updated. Any other functions that may do this for me?

    look at http://redhillsmedia.com the blogs are listed in the sidebar.

  2. Driftless1
    Member
    Posted 14 years ago #

    I asked a similar question a week ago, and have been met with uncharacteristic silence...

    Best I could come up with is using the List-All plugin, and sorting by path... which works for me (since the paths are roughly alphabetical) but doesn't look like it will work so well with you.

    if ($tmp_order == "blog_name") {
    			$order = "ORDER BY  path ASC";
    		}

    (Edit: I should point out, I added this in the section that handles the arguments from the function input... about line 90...)

    It shouldn't be too much more work to rewrite the plugin to join the database query and pull out the name, then sort by that - I just have not had the time to flesh that out since the simple way worked form me.

    Good luck.

  3. billjones
    Member
    Posted 14 years ago #

    I agree, I have been looking for the answer off and on for almost a year. I keep coming across 'name sort would make this function useful' a lot, but nobody has tacked it. sql-php isn't my forte so I ma kind of at a loss.

    If it's that hard, then I wish someone would just say it can't be done, but I am building a site that will have hd (30000x15000 pixel) panoramas of old churches and they will be listed by name otherwise once I get 20 or more it will just become to confusing for the visitor.

  4. jamescollins
    Member
    Posted 14 years ago #

    Do you mean listing the blogs alphabetically by their domain name?

    If so, something like this should work;

    global $wpdb;
    $blogs = $wpdb->get_results( "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ORDER BY domain ASC", ARRAY_A );

    If you want to list the blogs alphabetically by the title defined in each blog's title (defined in Settings -> General), then you will have to loop over the above query results, and do a get_blog_option(blog_id, 'blogname'), save that result in an array (along with the blog's URL), then manually sort the array using PHP.

    This could cause performance issues depending on the number of blogs you have though.

  5. andrea_r
    Moderator
    Posted 14 years ago #

    I thought there was a version of the List All plugin that did sort them by name.

    Did it here:
    http://wpmututorials.com/how-to/making-a-member-list-blog-directory/

  6. Driftless1
    Member
    Posted 14 years ago #

    Hi andrea -- I checked this out during my original quest, and the version of List-all that I can find (and the one on your tutorial) does not include a behavior for the 'blog_name' option. Not in the instructions:

    ORDER: Can be 'updated' which lists blogs by last updated, 'first_created' which lists blogs by the first blog to the latest, or 'last_created' which lists blogs from the latest to the first created

    and not in the code. That's why I added the custom sort order above to at least get it to order by path.

    Maybe the file has changed since you wrote that tutorial?

    Cheers

  7. andrea_r
    Moderator
    Posted 14 years ago #

    Or maybe I had a version with that change in it and forgot it wasn't in the one there. :D

  8. billjones
    Member
    Posted 14 years ago #

    Kicking this up as I still need a solution. Please check out RHMPano.organd you will see what I will be up against.

  9. andrea_r
    Moderator
    Posted 14 years ago #

    Bill, send me an email via my contact form.

    http://wpmututorials.com/contact/

    I'll go dig up the one I know sorts ABC.

  10. billjones
    Member
    Posted 14 years ago #

    That would be much appreciated. Thanks.

  11. billjones
    Member
    Posted 14 years ago #

    It didn't do it, it just locks up the admin section when activated site wide and gets an error upon single site activation. Thanks though.

    bILL

  12. andrea_r
    Moderator
    Posted 14 years ago #

    It absolutely needs to go in the mu-plugins folder.

  13. billjones
    Member
    Posted 14 years ago #

    Andrea is right.

    If you want to list your Blogs in the order of the Name you have given them, use the list_all.php plugin. Have it in the mu-plugins folder, and insert the following code into the sidebar

    "<?php
    list_all_wpmu_blogs('100', 'name', '<p>', '</p> ', 'blog_name'); ?>"

    blog_name is NOT covered in the txt file that comes with the plugin as a sort option, but it is.

    There are still some small issues to work out, like not including the home blog.

    Thanks for every ones help.

    Bill

  14. Driftless1
    Member
    Posted 14 years ago #

    Bill or andrea -- could you publically post that mod? I swear it's not int the native list-all plugin I've got. I would just like to look at the code.

    Thanks.

  15. andrea_r
    Moderator
    Posted 14 years ago #

    No, it's not in that one. Been meaning to post our modded version.. hang on.

  16. stcwebdesigns
    Member
    Posted 14 years ago #

    Has this been posted yet? It's exactly what I need, but doesn't seem to be in the latest version downloaded from the plugin page.

    Thanks
    Janie

  17. andrea_r
    Moderator
    Posted 14 years ago #

    Better yet, I found one that *was* posted...
    http://wpmudevorg.wordpress.com/project/Listem

  18. stcwebdesigns
    Member
    Posted 14 years ago #

    What a star! Thanks, Andrea. That's exactly what I needed.

    Janie

  19. SvenB
    Member
    Posted 14 years ago #

    Ive put the listem.php in the mu-pluginfolder.
    And ive made list.php file with the code to call the function, but it will not list any blogs, just an empty space..

    Is it possibel to call the function in a normal post?

  20. andrea_r
    Moderator
    Posted 14 years ago #

    Nope, no php in post content. That's why we've made a page template instead.

    If it's not listing any blogs, check and make sure your blog privacy settings are set to public.

    Can;t really say what's wrong without seeing any code / link to the page.

    (if you paste code, use pastebin.com and link to it instead of dumping in the forum)

  21. SvenB
    Member
    Posted 14 years ago #

    You can see the site here http://mkf.hig.se/mu/
    of some reason it cuts away all code under the "listem" function.

    here is the code http://pastebin.com/m7f848de8

  22. SvenB
    Member
    Posted 14 years ago #

    Any ideas?

  23. DeannaS
    Member
    Posted 14 years ago #

    It looks like the listem tag is generating an error of some sort. Check your php error logs.

  24. SvenB
    Member
    Posted 14 years ago #

    Yes I found some errors in the logs.
    http://pastebin.com/m3d346bee

  25. SvenB
    Member
    Posted 14 years ago #

    Its seems like it cant load the plugin? but why?
    Im not good enough at PHP to understand why.

  26. tim.moore
    Member
    Posted 14 years ago #

    Those errors mean that you haven't given Apache (or whatever web server you are using) permission to read those files. You need to set the files to read/write by the owner (you), and also give read access to the Web server (which is usually the www-data user).

  27. SvenB
    Member
    Posted 14 years ago #

    Ah, now I feel a bit stupid. I was so sure that the r/w access was correct that I didnt even look..
    Thanks Tim Moore and all others, you were correct and now it works great!

About this Topic