Recent Topics

1 Feb 18, 2010 23:24    

My b2evolution Version: Not Entered

Hi all,
question is can the blogs be reordered ie the blog id number can that be renumbered. reason is that the plugin for the other blogs list them in order of that id number. the alternative question is can that be forced to order them alphabetically?
The version of b2evo is 3.3.1.
best regards

2 Mar 14, 2010 21:46

Yes you can force it if you have access to your SQL DATABASE. If you do, you can change the ID number by going to Phpmyadmin and login, from there, you can change anything in your b2evolution database including ID numbers

3 Mar 14, 2010 22:30

changing blog id's in the db may not be the best idea, it could break certain things i assume

7 May 10, 2011 05:31

Sadly, that plug in didn't work for me either.

Neither has, thus far, changing the blog ID in the database.
Does anyone know if this will be a feature coming up in a later release?

8 May 10, 2011 05:38

There's a VERY easy way to do what I think you're trying to do. It's the Sorted Public Bloglist plugin. For some reason i can't find it but I'll email it to you (I downloaded it long ago). I'll zip it and rename the extension to .b2e so it gets through your email blockers. Just rename to .zip and install as normal plugin. PM me your email address and I'll send it over. Or you can try finding it but at a cursory look I didn't see it posted... I'm not sure why it'd be taken down but like I said, I've got it.

!!! UPDATE !!!

Now that I look at it, it's only a single php file so I can just send it as is. Just drop into your plugins folder, install and you're good to go.

9 May 10, 2011 05:45

For that matter, here's the code:

<?php
/**
 * Amazing Discoveries sortable bloglist plugin.
 *
 * @package plugins
 *
 * @copyright (c)2008 by Foppe Hemminga - {@link http://www.blog.hemminga.net/}.
 * 
 * Based on the AM Bloglist plugin.
 * ;liu/987--
 *  (c)2007 by AstonishMe - {@link http://astonishme.co.uk/}.
 * 
 * {@internal Below is a list of authors who have contributed to design/coding of this file: }
 * @author Yabba	- {@link http://www.astonishme.co.uk/}
 * @author Stk		- {@link http://www.astonishme.co.uk/}
 *
 * @license GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
 *
 * @package plugins
 */

if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );

class sorted_bloglist_plugin extends Plugin
{
	var $name = 'Sorted Public bloglist';
	var $code = 'sorted_bloglist';
	var $priority = 50;
	var $version = '0.9.1';
	var $author = 'Foppe Hemminga';
	var $group = 'Amazing Discoveries';
	var $help_url = 'http://www.blog.hemminga.net/index.php/2008/02/09/sorted-public-bloglist?blog=8';
	var $apply_rendering = 'never';
	var $number_of_installs = 1;
	/**
	 * @internal
	 */
	var $disp_params = array();
	
	var $allBlogs = array();
	var $BlogCache;

	function PluginInit()
	{
		$this->short_desc = T_( 'Amazing Discoveries - Sorted Public bloglist' );
		$this->long_desc = T_( 'This widget allows you to arrange the order of the blogs in the Public Bloglist. It can replace the Public Blog list widget.');
	}


	function GetDefaultSettings()
	{
		$r = array(
			'standard_begin' => array(
				'label' => $this->T_( 'Standard options' ),
				'layout' => 'begin_fieldset'
			),
			'title' => array(
				'label' => $this->T_( 'Title' ),
				'type' => 'text',
				'defaultvalue' => '',
				'note' => $this->T_( 'Leave empty for bloglist in \'Page Top\' or add a text for bloglist in other container.' )
				),
			'available_blogs' => array(
				'label' => $this->T_( 'Available public blogs' ),
				'defaultvalue' => $this->get_public_blogs(),
				'type' => 'text',
				'size' => 40,
				'note' => $this->T_( 'This is a list of all avalable and public blogs. Arrange them.' )
				),
			'sort_random' => array(
				'label' => $this->T_( 'Sort them random' ),
				'type' => 'checkbox',
				'defaultvalue' => false,
				'note' => $this->T_( 'For those adventurous sorts the Public Blogs randomly. Overrides manual setting' )
				),
			'link_title' => array(
				'label' => $this->T_( 'Appearance in blogroll' ),
				'type' => 'select',
				'defaultvalue' => 'short',
				'options' => array( 'long' => $this->T_( 'Full title' ), 'short' => $this->T_( 'Short name' ), 'shortdesc' => $this->T_( 'Short description' ) ),
				'note' => $this->T_( 'Choose between the Short name or the Full title or the \'Short description\' in the blogroll' )	
				),
			'standard_end' => array(
				'layout' => 'end_fieldset'
			),
			'advanced_begin' => array(
				'label' => $this->T_( 'Advanced options' ),
				'layout' => 'begin_fieldset'
			),
			'owner_member_begin' => array(
				'label' => $this->T_( 'Add owner / member blogs' ),
				'layout' => 'begin_fieldset'
			),
			'show_owner_blogs' => array(
				'label' => $this->T_( 'Show Owner blogs' ),
				'type' => 'checkbox',
				'defaultvalue' => false,
				'note' => $this->T_( 'If checked, shows public blogs *plus* hidden blogs where a user is \'Owner\' of. It DOES NOT protect a blog from view to the world.' )
			),
			'show_member_blogs' => array(
				'label' => $this->T_( 'Show Member blogs' ),
				'type' => 'checkbox',
				'defaultvalue' => false,
				'note' => $this->T_( 'If checked, shows public blogs *plus* hidden blogs where a user is \'Member\' of. It DOES NOT protect a blog from view to the world.' )
			),
			'owner_member_end' => array(
				'layout' => 'end_fieldset'
			),
			'extra_links_begin' => array(
				'label' => $this->T_( 'Add freestyle Extra links' ),
				'layout' => 'begin_fieldset'
			),			
			'extra_link_bool' => array(
				'label' => $this->T_( 'Add extra (external) links' ),
				'type' => 'checkbox',
				'defaultvalue' => false	
			),		
			'extra_link_url' => array(
				'label' =>$this->T_( 'Provide the URL to the location' ),
				'type' => 'text',
				'defaultvalue'=> '',
				'size' => 80,
				'note' => $this->T_( 'Add a link (URL starting with http:// or relative ../). More than one link seperated by comma.' )
			// fh> @TODO Check for reasonable valid URL
			),
			'extra_link_label' => array(
				'label' => $this->T_( 'Label (text) in Blogroll' ),
				'type' => 'text',
				'defaultvalue' => '',
				'size' => 40,
				'note' => $this->T_( 'Add a label like \'Forum\'. Make sure you have as much titles as links. Also comma seperated.' )
			// fh> TODO Check for empty and decide what to do when empty
			),
			'extra_link_end' => array(
				'layout' => 'end_fieldset'
			),
			'advanced_end' => array(
				'layout' => 'end_fieldset'
			)
			// fh> TODO See if I can do a 'more' button with more extra links
		);

		return $r;
	}


	/**
   * Get definitions for widget specific editable params
   *
	 * @see Plugin::GetDefaultSettings()
	 * @param local params like 'for_editing' => true
	 */
	function get_widget_param_definitions()
	{
		$r = $this->GetDefaultSettings();
		return $r;
	}


	function SkinTag( $params )
	{ // These params contain $placeholders$ that are being replaced later
		$params['item_selected'] = '<li class="selected"><a href="$blog_url$" title="" class="mBlog$blog_ID$ selected">$blog_name$</a></li>';
		$params['item_normal'] = '<li><a href="$blog_url$" title="" class="mBlog$blog_ID$ default">$blog_name$</a></li>';
		$params['items_before'] = '<div class="widget_core_colls_list_public widget_plugin_sorted_bloglist">';
		$params['items_after'] = '</div>';
		$this->init_display( $params );
		
		$this->show_blogs( $params );

		echo $this->disp_params['list_end']."\n";
		echo $this->disp_params['items_after']."\n";		
		echo $this->disp_params['block_end']."\n";
	}

	
	function show_blogs( $params )
	{
		global $Blog;

		$public_blogs = $this->get_selected_blogs();

		if ( $this->disp_params[ 'sort_random' ] )
		{
			shuffle( $public_blogs );
		}
		
		$blogKeys = array();
		foreach( $public_blogs as $a_blog )
		{	// load each blog
			$temp = $this->BlogCache->get_by_ID( $a_blog );
			$this->allBlogs[ $a_blog ] = $temp;
			$blogKeys[] = $a_blog;
			unset( $temp );
		}

		// Start the output
		echo $this->disp_params['block_start']."\n";
		echo $this->disp_params['items_before']."\n";
		if( $this->disp_params[ 'title' ] )
		{
			// echo '<h2>' . $this->disp_params[ 'title' ] . '</h2>' . "\n";
			ComponentWidget::disp_title( $this->disp_params[ 'title' ] );
			// TODO get the 'official' path to this method
		}
		echo $this->disp_params[ 'list_start' ]."\n";
		if( $params[ 'link_title' ] == 'short' )
		{
			$link_title = 'shortname';
		}
		elseif ( $params[ 'link_title' ] == 'long' )
		{
			$link_title = 'name';
		}
		elseif ( $params[ 'link_title' ] == 'shortdesc' )
		{
			$link_title = 'shortdesc';
		}
		foreach( $public_blogs as $blogKey )
		{ // Loop through all blogs:
			$aBlog = $this->allBlogs[ $blogKey ];
			if( $Blog && $aBlog->ID == $Blog->ID )
			{ // This is the blog being displayed on this page:
  				$output = $this->disp_params[ 'item_selected' ];
			}
			else
			{
				$output = $this->disp_params[ 'item_normal' ];
			}

			// replace any values
			echo str_replace( array( '$blog_url$', '$blog_name$', '$blog_ID$' ),
					array( 		$aBlog->gen_blogurl(),
								$aBlog->dget( $link_title, 'htmlbody' ),
								$aBlog->ID,
					),
					$output ) . "\n";
		}
		if ( $this->disp_params[ 'extra_link_bool' ] )
		{ // Add freestyle links to your Blogroll
			$this->display_extra_links();
		}
	}
	

	function get_sorted_blogs()
	{
		$sort_blogs = $this->disp_params[ 'available_blogs' ]; // disp_params because it takes Settingsa from the widget, not the plugin
		$sort_blogs = str_replace(' ', '', $sort_blogs);
		$sort_blogs = explode( ',', $sort_blogs);
		$get_all_Blogs = array();
		// Delete non existent Blogs from list (the list is edited by the user)	
		foreach( $sort_blogs as $curr_blog_ID )
		{
			// Get blog:
			$loop_Blog = & $this->BlogCache->get_by_ID( $curr_blog_ID, false );
			if( empty($loop_Blog) )
			{	// That one doesn't exist (any more?)
				continue;
			}
			$get_all_Blogs[] = $curr_blog_ID; // Build a new array
		}
		return $get_all_Blogs;
	}
	
	
	function get_owner_blogs()
	{ // Get blogs the user is 'Owner' of
		global $Blog;
		$BlogCache = & get_Cache( 'BlogCache' );
		
		$owner_blogs = $BlogCache->load_owner_blogs( $Blog->get( 'owner_user_ID' ) );
		return $owner_blogs;		
	}
	
	
	function get_member_blogs()
	{ // Get blogs the user is 'Owner' of
		$BlogCache = & get_Cache( 'BlogCache' );
		
		$member_blogs = $BlogCache->load_user_blogs();
		return $member_blogs;		
	}
	
	
	function get_public_blogs()
	{ // Get a list of 'Public Blogs'
		$this->BlogCache = & get_Cache( 'BlogCache' );
		// pre_dump($this->BlogCache);		
		$pub_blogs = $this->BlogCache->load_public();
		$pub_blogs = implode( ', ', $pub_blogs );
		return $pub_blogs;
	}
	
	
	function get_selected_blogs()
	{ // Gather all blogs that need displaying
		// TODO the implementation of member blogs is different than ownerblogs
		// Could do with the shorter owner blogs implementation
		$public_blogs = array();
		$owner_blogs = array();
		$member_blogs = array();
		if ($this->disp_params[ 'show_owner_blogs' ] && is_logged_in() )
		{
			$owner_blogs = $this->get_owner_blogs();
			// DEBUG with FirePHP
			// fb($owner_blogs, '$owner_blogs', FirePHP::LOG);
		}
		if ( $this->disp_params[ 'show_member_blogs' ] && is_logged_in() )
		{ // Fetch public blogs, arranged in plugin Settings
			$member_blogs = $this->get_member_blogs();
			// DEBUG with FirePHP
			// fb($member_blogs, 'member_blogs', FirePHP::LOG);
		}
		else
		{ // fetch public blogs, arranged in plugin Settings
			$public_blogs = $this->get_sorted_blogs();
			// DEBUG with FirePHP
			// fb($public_blogs, 'arranged and checked public_blogs', FirePHP::LOG);
		}
		// DEBUG with FirePHP
		// fb($public_blogs, '$public_blogs');
		
		$public_blogs = array_merge( $public_blogs, $owner_blogs, $member_blogs );
		$public_blogs = array_unique( $public_blogs );
		// DEBUG with FirePHP
		// fb($public_blogs, 'merged blogs unique', FirePHP::LOG);

		return $public_blogs;
	}
	
	
	function display_extra_links()
	{ // Add freestyle extra links to the end of the Blogroll
		// Since the links are outside B2evolution they are never 'selected' so pick 'item_normal'
		$output = $this->disp_params[ 'item_normal' ];
		$str_extra_links_url = str_replace( ', ', ',', $this->disp_params[ 'extra_link_url' ] );
		$str_extra_links_label = str_replace( ', ', ',', $this->disp_params[ 'extra_link_label' ] );
		$array_extra_links_url = explode( ',', $str_extra_links_url );
		if ( $array_extra_links_url[ 0 ] == '' )
		{ // Get rid of empty string '' as first array item in case of no url given
			array_pop( $array_extra_links_url );
		}
		$array_extra_links_label = explode( ',', $str_extra_links_label );
		if ( $array_extra_links_label[ 0 ] == '' )
		{ // Get rid of empty string '' as first array item in case of no label given
			array_pop( $array_extra_links_label );
		}
		// You'd better make sure there are enough labels ;)
		$spam = array( 'Porn', 'Penis', 'Viagra' );
		$j = 0;
		$k = 0;
		while ( $j < count( $array_extra_links_url ) )
		{
			if ( ! array_key_exists( $j, $array_extra_links_label ) )
			{
				$array_extra_links_label[ $j ] = $spam[ $k ];
				if ( $k == 2 )
				{ // Enough fun for now
					$array_extra_links_url = array_slice( $array_extra_links_url, 0,  3 );
				}
				$k++;
			}
			$j++;
		}
		$i = 0;
		while ( $i < count( $array_extra_links_url ) )
		{
			echo str_replace( array( '$blog_url$', '$blog_name$', '$blog_ID$' ),
			array(		$array_extra_links_url[ $i ],
						$array_extra_links_label[ $i ],
						'_extra_link'
			),
			$output ) . "\n";
			$i++;
		}
	}

	/**
	 * Sets all the display parameters
	 * these will either be the default display params
	 * or the widget display params if it's in a container
	 *
	 * @param array $params
	 */
	function init_display( $params = array() )
	{ // Merge Default settings (from this plugin) with basic widget settings into array $disp_params
		$temp = $this->get_widget_param_definitions( array() );
		foreach( $temp as $setting => $values )
			$this->disp_params[ $setting ] = ( isset( $params[ $setting ] ) ? $params[ $setting ] : $this->Settings->get( $setting ) );

		foreach( $params as $param => $value )
			$this->disp_params[ $param ] = $value;
	}
	
	
	function SkinBeginHtmlHead()
	{ // Removes class .widget_core_colls_list_public if the widget is in the sidebar
		// TODO Do this through PHP
		require_js( '#jquery#' );
		add_headline( '<script type="text/javascript">
		jQuery(document).ready(function() {
			jQuery(\'#sidebar div.widget_plugin_sorted_bloglist\').removeClass(\'widget_core_colls_list_public\')
		})
	</script>' );
	}
}
?>

Just copy into a file, save as _sorted_bloglist.plugin.php and you're good to go.

10 May 24, 2011 13:18

Ethan, you are a kind, kind soul! Thank you!

Many blessings to you, friend.


Form is loading...

b2evolution CMS – This forum is powered by b2evolution CMS, a complete engine for your website.