Recent Topics

1 Feb 15, 2012 23:46    

This is by far one of the most asked things.I dont understand why still there is not an option for the order of the blogs other than id..

2 Feb 16, 2012 01:16

I thought about a global and widget settings to control blog ordering. In fact I already use these hacks on one of my client's blog.

The global settings will control ordering of blogs in the main menu and in category list fieldset (in case of crossblog posting)

I will try to add it in v5

3 Feb 16, 2012 01:26

sam2kb wrote:

I thought about a global and widget settings to control blog ordering. In fact I already use these hacks on one of my client's blog.

The global settings will control ordering of blogs in the main menu and in category list fieldset (in case of crossblog posting)

I will try to add it in v5

cool.can you share the hack ?

4 Feb 16, 2012 02:23

Will these options work for you?

return array(
	'ID'           => T_('Blog ID (Default)'),
	'name'         => T_('Name'),
	'shortname'    => T_('Short name'),
	'tagline'      => T_('Tagline'),
	'description'  => T_('Description'),
	'urlname'      => T_('URL "filename"'),
	'RAND'         => T_('Random order!'),
);

I'm working on a complete feature, hacks will do no good.

5 Feb 16, 2012 02:53

sam2kb wrote:

Will these options work for you?

return array(
	'ID'           => T_('Blog ID (Default)'),
	'name'         => T_('Name'),
	'shortname'    => T_('Short name'),
	'tagline'      => T_('Tagline'),
	'description'  => T_('Description'),
	'urlname'      => T_('URL "filename"'),
	'RAND'         => T_('Random order!'),
);

I'm working on a complete feature, hacks will do no good.

That's more than enough !
Btw, i have just now made a CVS checkoout and will upgrade with this checkout, hope everything is stable out there : D

6 Feb 16, 2012 15:10

CVS is very outdated, we don't use CVS. The version 4.1.3 should be released very soon. You may want to wait if there's no rush.

7 Feb 16, 2012 15:11

However 4.1.3 will only have bugfixes, no new features at all.

8 Feb 16, 2012 17:25

Added to v5

Here's what you need to change to make it work in v4
Update these 2 functions in /inc/collections/model/_blogcache.class.php

/**
 * Load a list of public blogs into the cache
 *
 * @param string
 * @return array of IDs
 */
function load_public( $order_by = 'ID', $order_dir = 'ASC' )
{
	global $DB, $Debuglog;

	$Debuglog->add( "Loading <strong>$this->objtype(public)</strong> into cache", 'dataobjects' );

	$SQL = new SQL();
	$SQL->SELECT( '*' );
	$SQL->FROM( $this->dbtablename );
	$SQL->WHERE( 'blog_in_bloglist <> 0' );
	$SQL->ORDER_BY( gen_order_clause( $order_by, $order_dir, 'blog_', 'blog_ID' ) );

	foreach( $DB->get_results( $SQL->get(), OBJECT, 'Load public blog list' ) as $row )
	{	// Instantiate a custom object
		$this->instantiate( $row );
	}

	return $DB->get_col( NULL, 0 );
}


/**
 * Load a list of blogs owner by specific ID into the cache
 *
 * @param integer
 * @param string
 * @return array of IDs
 */
function load_owner_blogs( $owner_ID, $order_by = 'ID', $order_dir = 'ASC' )
{
	global $DB, $Debuglog;

	$Debuglog->add( "Loading <strong>$this->objtype(owner={$owner_ID})</strong> into cache", 'dataobjects' );

	$SQL = new SQL();
	$SQL->SELECT( '*' );
	$SQL->FROM( $this->dbtablename );
	$SQL->WHERE( 'blog_owner_user_ID = '.$DB->quote($owner_ID) );
	$SQL->ORDER_BY( gen_order_clause( $order_by, $order_dir, 'blog_', 'blog_ID' ) );

	foreach( $DB->get_results( $SQL->get(), OBJECT, 'Load owner blog list' ) as $row )
	{	// Instantiate a custom object
		$this->instantiate( $row );
	}

	return $DB->get_col( NULL, 0 );
}

update this func in /inc/widgets/model/_widget.class.php

/**
 * List of collections/blogs
 *
 * @param array MUST contain at least the basic display params
 */
function disp_coll_list( $filter = 'public', $order_by = 'ID', $order_dir = 'ASC' )
{
	/**
	 * @var Blog
	 */
	global $Blog, $baseurl;

	echo $this->disp_params['block_start'];

	$this->disp_title();

	/**
	 * @var BlogCache
	 */
	$BlogCache = & get_BlogCache();

	if( $filter == 'owner' )
	{	// Load blogs of same owner
		$blog_array = $BlogCache->load_owner_blogs( $Blog->owner_user_ID, $order_by, $order_dir );
	}
	else
	{	// Load all public blogs
		$blog_array = $BlogCache->load_public( $order_by, $order_dir );
	}

	// 3.3? if( $this->disp_params['list_type'] == 'list' )
	// fp> TODO: init default value for $this->disp_params['list_type'] to avoid error
	{
		echo $this->disp_params['list_start'];

		foreach( $blog_array as $l_blog_ID )
		{	// Loop through all public blogs:

			$l_Blog = & $BlogCache->get_by_ID( $l_blog_ID );

			if( $Blog && $l_blog_ID == $Blog->ID )
			{ // This is the blog being displayed on this page:
			echo $this->disp_params['item_selected_start'];
				$link_class = $this->disp_params['link_selected_class'];
			}
			else
			{
				echo $this->disp_params['item_start'];
				$link_class = $this->disp_params['link_default_class'];;
			}

			echo '<a href="'.$l_Blog->gen_blogurl().'" class="'.$link_class.'" title="'
										.$l_Blog->dget( 'name', 'htmlattr' ).'">';

			if( $Blog && $l_blog_ID == $Blog->ID )
			{ // This is the blog being displayed on this page:
				echo $this->disp_params['item_selected_text_start'];
				printf( $this->disp_params['item_selected_text'], $l_Blog->dget( 'shortname', 'htmlbody' ) );
				echo $this->disp_params['item_selected_text_end'];
				echo '</a>';
				echo $this->disp_params['item_selected_end'];
			}
			else
			{
				echo $this->disp_params['item_text_start'];
				printf( $this->disp_params['item_text'], $l_Blog->dget( 'shortname', 'htmlbody' ) );
				echo $this->disp_params['item_text_end'];
				echo '</a>';
				echo $this->disp_params['item_end'];
			}
		}

		echo $this->disp_params['list_end'];
	}
	/* 3.3?
		Problems:
		-In FF3/XP with skin evoCamp, I click to drop down and it already reloads the page on the same blog.
		-Missing appropriate CSS so it displays at least half nicely in most of teh default skins
	{
		$select_options = '';
		foreach( $blog_array as $l_blog_ID )
		{	// Loop through all public blogs:
			$l_Blog = & $BlogCache->get_by_ID( $l_blog_ID );

			// Add item select list:
			$select_options .= '<option value="'.$l_blog_ID.'"';
			if( $Blog && $l_blog_ID == $Blog->ID )
			{
				$select_options .= ' selected="selected"';
			}
			$select_options .= '>'.$l_Blog->dget( 'shortname', 'formvalue' ).'</option>'."\n";
		}

		if( !empty($select_options) )
		{
			echo '<form action="'.$baseurl.'" method="get">';
			echo '<select name="blog" onchange="this.form.submit();">'.$select_options.'</select>';
			echo '<noscript><input type="submit" value="'.T_('Go').'" /></noscript></form>';
		}
	}
	*/
	echo $this->disp_params['block_end'];
}

add this func to /inc/_core/_misc.funcs.php

/**
 * Get available cort oprions for blogs 
 *
 * @return array key=>name
 */
function get_coll_sort_options()
{
	return array(
		'ID'           => T_('Blog ID (Default)'),
		'name'         => T_('Name'),
		'shortname'    => T_('Short name'),
		'tagline'      => T_('Tagline'),
		'description'  => T_('Description'),
		'urlname'      => T_('URL "filename"'),
		'RAND'         => T_('Random order!'),
	);
}

update the widgets _colls_list_owner.widget.php and _colls_list_public.widget.php
Add settings

'order_by' => array(
	'label' => T_('Order by'),
	'note' => T_('How to sort the blogs'),
	'type' => 'select',
	'options' => get_coll_sort_options(),
	'defaultvalue' => 'ID',
),
'order_dir' => array(
	'label' => T_('Direction'),
	'note' => T_('How to sort the blogs'),
	'type' => 'radio',
	'options' => array( array( 'ASC', T_('Ascending') ), 
						array( 'DESC', T_('Descending') ) ),
	'defaultvalue' => 'DESC',
),

And replace

$this->disp_coll_list( 'WHATEVER' );


with

$this->disp_coll_list( 'WHATEVER', $this->disp_params['order_by'], $this->disp_params['order_dir'] );

9 Mar 07, 2012 03:30

Did the changes, everything works like a charm ! Those are great options to sort the blogs.

However what i was after was a manual order which i would decide, not by title or desc. etc.

Finally, in the output, it might come handy to have <li id="Blog_ID">

10 Mar 07, 2012 07:18

I don't think anyone is going to add manual blog order in the near future. It's a lot of work :(

11 Mar 07, 2012 13:25

sam2kb wrote:

I don't think anyone is going to add manual blog order in the near future. It's a lot of work :(

How can i at least <li id="Blog_ID"> so that i can manually adjust them via css ?

12 Mar 07, 2012 14:54

Replace

echo '<a href="'.$l_Blog->gen_blogurl().'" class="'.$link_class.'"

with

echo '<a href="'.$l_Blog->gen_blogurl().'" id="blog_'.$l_Blog->ID.'" class="'.$link_class.'"

13 Mar 08, 2012 00:51

With regard to blog reordering - why not just use the Sorted Public Bloglist widget?

14 Mar 08, 2012 01:52

Ethan5150 wrote:

With regard to blog reordering - why not just use the Sorted Public Bloglist widget?

Right !! I totally forgot about that.Damn thing still works.That was just what i needed.thanks for the heads up

15 Mar 08, 2012 02:09

Every once in a while I'm useful :)


Form is loading...