Recent Topics

1 Apr 02, 2005 09:31    

I wanted the blogs in the bloglist to be sorted alphabetically... Right now they sort by the order in which they were created... which I don't really care for. ./b2/blogs/skins/myskin/_bloglist.php becomes:


<?php
	/**
	 * This is the template that displays the links to the available blogs
         * And now it sorts the blogs alphabetically --ben
	 *
	 * This file is not meant to be called directly.
	 * It is meant to be called by an include in the _main.php template.
	 *
	 * b2evolution - {@link http://b2evolution.net/}
	 * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
	 * @copyright (c)2003-2004 by Francois PLANQUE - {@link http://fplanque.net/}
	 *
	 * @package evoskins
	 */
	if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );

if( ! $display_blog_list )
{ // We do *not* want the blog list to be displayed
	return;
}

# this is what will start and end your blog links
if(!isset($blog_list_start)) $blog_list_start = '<ul id="bloglist">';
if(!isset($blog_list_end)) $blog_list_end = '</ul>';
# this is what will separate your blog links
if(!isset($blog_item_start)) $blog_item_start = '<li>';
if(!isset($blog_item_end)) $blog_item_end = "</li>\n";
# This is the class of for the selected blog link:
if(!isset($blog_selected_link_class)) $blog_selected_link_class = 'BlogButtonCurr';
# This is the class of for the other blog links:
if(!isset($blog_other_link_class)) $blog_other_link_class = 'BlogButton';
# This is additionnal markup before and after the selected blog name
if(!isset($blog_selected_name_before)) $blog_selected_name_before = '';
if(!isset($blog_selected_name_after)) $blog_selected_name_after = '';
# This is additionnal markup before and after the other blog names
if(!isset($blog_other_name_before)) $blog_other_name_before = '';
if(!isset($blog_other_name_after)) $blog_other_name_after = '';
# This is the blogparam that will be displayed as the name:
if(!isset($blog_name_param)) $blog_name_param = 'shortname';
# This is the blogparam that will be displayed as the link title:
if(!isset($blog_title_param)) $blog_title_param = 'name';


// first we go through and get info about all the blogs, printing nothing
$i=0;
for( $curr_blog_ID = blog_list_start();
			$curr_blog_ID != false;
			 $curr_blog_ID = blog_list_next() )
{
	if( !blog_list_iteminfo( 'in_bloglist', false ) )
	{ // don't show
		continue;
	}

	$array_blog_name[blog_list_iteminfo($blog_name_param, '')]=$i;

	$array_blog_ID[$i]=$curr_blog_ID;
	$array_blog_url[$i]=blog_list_iteminfo('blogurl', '');
	$array_blog_title[$i]=blog_list_iteminfo($blog_title_param, '');

	$i++;
}

// now we sort the blog info alphabetically by sorting array_blog_name
ksort($array_blog_name);

// now we print the sorted blog info
echo $blog_list_start;
foreach($array_blog_name as $key=>$val)
{
//	 print "$key : $val<br>";

	echo $blog_item_start;
	if( $array_blog_ID[$val] == $blog )
	{ // This is the blog being displayed on this page:
		echo '<a href="';
		echo $array_blog_url[$val];
		echo '" class="', $blog_selected_link_class, '" title="';
		echo $array_blog_title[$val];
		echo '">';
		echo $blog_selected_name_before;
		echo $key;
		echo $blog_selected_name_after;
		echo '</a>';
	}
	else
	{ // This is another blog:
		echo '<a href="';
		echo $array_blog_url[$val];
		echo '" class="', $blog_other_link_class, '" title="';
		echo $array_blog_title[$val];
		echo '">';
		echo $blog_other_name_before;
		echo $key;
		echo $blog_other_name_after;
		echo '</a>';
	} // End of testing which blog is being displayed
	echo $blog_item_end;
}
echo $blog_list_end;

?>


2 Apr 21, 2005 03:45

Is there a way to order the blog list "manually"... I mean... in the exact order I want instead of alphabetically nor cronologically... :-)

thanks,

3 Apr 21, 2005 04:26

The blog list is called in _main.php toward the top. If you replace the call to bloglist.php (there's a comment that says BLOGLIST INCLUDED HERE) with your own bloglist html, then you can order it how you want to.

Here's my bloglist... yours would look similar.


  <ul id="bloglist"><li><a href="http://nonplatonic.com/index.php" class="BlogButtonCurr" title="nonplatonic">nonplatonic</a></li>
<li><a href="http://nonplatonic.com/index.php/anwar" class="BlogButton" title="Anwar">Anwar</a></li>
<li><a href="http://nonplatonic.com/index.php/ben" class="BlogButton" title="Ben">Ben</a></li>
<li><a href="http://nonplatonic.com/index.php/collin" class="BlogButton" title="Collin">Collin</a></li>
<li><a href="http://nonplatonic.com/index.php/devin" class="BlogButton" title="A Hole in the World">Devin</a></li>
<li><a href="http://nonplatonic.com/index.php/graham" class="BlogButton" title="Graham">Graham</a></li>
<li><a href="http://nonplatonic.com/index.php/marco" class="BlogButton" title="Marco">Marco</a></li>
<li><a href="http://nonplatonic.com/index.php/scott" class="BlogButton" title="Scott">Scott</a></li>
</ul>

4 Apr 21, 2005 05:57

I did it and worked fine! thanks,


Form is loading...