Recent Topics

1 May 27, 2009 12:27    

My b2evolution Version: 2.x

Is there anyway to change the bloglist from buttons to a dropdown menu?

2 May 27, 2009 20:33

of course,as it's already a list.there's thousands of css & jquery dropdown menu's around, just grab one and adjust it accordingly

3 May 28, 2009 08:25

Yes, but the code is at the moment like this:
<li><a href="link">Title</a></li>

If I change it to a dropdown menu without any code changes it reads:
<option><a href="link">Title</a></option>

when it should read:
<option value="link">Title</option>

4 May 28, 2009 09:07

Here's a quick hack

1. Replace the whole function "disp_coll_list" from inc/widgets/model/_widget.class.php with this one

/**
 * List of collections/blogs
 *
 * @param array MUST contain at least the basic display params
 * @param string possible values: list, form
 */
function disp_coll_list( $filter = 'public' )
{
	/**
	 * @var Blog
	 */
	global $Blog, $baseurl;

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

	$this->disp_title( T_('Blogs') );

	/**
	 * @var BlogCache
	 */
	$BlogCache = & get_Cache( 'BlogCache' );

	if( $filter == 'owner' )
	{	// Load blogs of same owner
		$blog_array = $BlogCache->load_owner_blogs( $Blog->owner_user_ID, 'ID' );
	}
	else
	{	// Load all public blogs
		$blog_array = $BlogCache->load_public( 'ID' );
	}
	
	if( $this->disp_params['type'] == 'list' )
	{
		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'];
				echo $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'];
				echo $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'];
	}
	else
	{
		$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'];
}

Then add the following code to inc/widgets/widgets/_colls_list_owner.widget.php and inc/widgets/widgets/_colls_list_public.widget.php on line 92

replace

'title' => array(
	'label' => T_( 'Title' ),
	'size' => 40,
	'note' => T_( 'This is the title to display, $icon$ will be replaced by the feed icon' ),
	'defaultvalue' => T_('My blogs'),
),


with this

'title' => array(
	'label' => T_( 'Title' ),
	'size' => 40,
	'note' => T_( 'This is the title to display, $icon$ will be replaced by the feed icon' ),
	'defaultvalue' => T_('My blogs'),
),
'type' => array(
	'label' => T_( 'Display type' ),
	'type' => 'select',
	'defaultvalue' => 'list',
	'options' => array( 'list' => T_('List'), 'form' => T_('Select menu') ),
	'note' => T_( 'How do you want to display blogs?' ),
),

Then in widget settings you can choose whether you want to display a regular "List" or a "Select menu"

8 May 28, 2009 10:06

Encountered one problem though. I cannot find the following code:

'title' => array(
    'label' => T_( 'Title' ),
    'size' => 40,
    'note' => T_( 'This is the title to display, $icon$ will be replaced by the feed icon' ),
    'defaultvalue' => T_('My blogs'),
),

9 May 28, 2009 10:10

Oops.. b2evo 2.4 doesn't have this code. Just add the whole function somewhere in those 2 widgets.

function get_param_definitions( $params )
{
	global $use_strict;
	$r = array_merge( array(
			'title' => array(
				'label' => T_( 'Title' ),
				'size' => 40,
				'note' => T_( 'This is the title to display, $icon$ will be replaced by the feed icon' ),
				'defaultvalue' => T_('My blogs'),
			),
			'type' => array(
				'label' => T_( 'Display type' ),
				'type' => 'select',
				'defaultvalue' => 'list',
				'options' => array( 'list' => T_('List'), 'form' => T_('Select menu') ),
				'note' => T_( 'How do you want to display blogs?' ),
			),
		), parent::get_param_definitions( $params )	);

	return $r;
}

13 Dec 31, 2010 12:42

I have just installed the latest version 4.0.3

Is the advice previously posted for question: "Is there anyway to change the bloglist from buttons to a dropdown menu?" still current and correct?

14 Dec 31, 2010 19:58

Try to apply the above hack, you may need to edit it a bit since it was originally coded for b2evo 2

15 Jan 01, 2011 04:25

Thanks. Worked just fine with hacks suggested.
May I suggest that this be made a standard feature of b2evo.


Form is loading...