WordPress.org

Ready to get started?Download WordPress

Forums

Multiple category selection hack? (2 posts)

  1. hudson2001
    Member
    Posted 1 year ago #

    I recently moved from b2evolution where I had a cool piece of code that allowed me to select multiple categories as a search. It was called Before & After Categories Plugin (if I remember right, it was written after I requested it) and it worked like a charm--it generated selection boxes before each category and radio buttons for ANY, ANY BUT, and ALL.

    WordPress has a much better search feature, but I'd still like to have the multiple category selector as I often want to search for a group of posts that wouldn't come up with a search. (For example, if I type "firsts and owen" in the search box, I get a result of one post. But I know there are at least 25 posts that are tagged with both the Firsts and Owen categories.)

    I've looked at all the category selector plugins but haven't found anything that gives the result I'd like. Is there one I'm missing? Is this something that can easily be written?

    Here's a sample photo (from the Wayback Machine) since I obviously no longer have that blog setup (it's moved here).

    Link to photo

  2. hudson2001
    Member
    Posted 1 year ago #

    Okay, I found the two PHP files used for the plugin. Can these be modified to work on WordPress?

    Here is one of the files content:

    <?php
    /**
     * This file implements the Lottery Plugin
     *
     *
     */
    if( !defined( 'EVO_MAIN_INIT' ) ) die( 'Please, do not access this page directly.' );
    
    /**
     * Random Picture Plugin Widget
     *
     * This widget displays a randomly chosen lottery balls in the sidebar or in another container
     *
     * @package plugins
     */
    class after_categories_plugin extends Plugin
    {
    	/**
    	* Variables below MUST be overriden by plugin implementations,
    	* either in the subclass declaration or in the subclass constructor.
    	*/
    	var $name = 'After Categories';
    	var $code = 'submit2';
    	var $priority = 99;
    	var $version = '0.1';
    	var $author = 'Foppe Hemminga';
    	var $help_url = 'http://www.blog.hemminga.net/';
    	var $group = 'Amazing Discoveries';
    	var $debug_this_widget = 0;
    
    	function PluginInit( & $params )
    	{
    		$this->short_desc = $this->T_( 'This widget creates a submit button for the Categories widget.' );
    		$this->long_desc = $this->T_( 'This widget must be placed in the same container after the Catgories widget.' );
    	}
    
    	/**
    	*
    	* Settings for this widget
    	* The current_draw and date_current_draw are hidden settings (not adjustable by user)
    	* needed to get the settings in the database.
    	* This is a workaround for a real database table structure.
    	*
    	*/
    	function GetDefaultSettings()
    	{
    		return array(
    
    			);
    	}
    
    	/**
    	* Get definitions for widget specific editable params
    	*
    	* @see Plugin::GetDefaultSettings()
    	* @param local params like 'for_editing' Arrow true
    	*/
    	function get_widget_param_definitions( $params )
    	{
    		return array(
    
    			);
    	}
    
    	/**
    	* 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() )
    	{
    		$temp = $this->get_widget_param_definitions( array() );
    		$full_params = array();
    		foreach( $temp as $setting => $values )
    			$full_params[ $setting ] = ( isset( $params[ $setting ] ) ? $params[ $setting ] : $this->Settings->get( $setting ) );
    		foreach( $params as $param => $value )
    			$full_params[ $param ] = $value;
    		return $full_params;
    	}
    
    	function SkinTag( $params )
    	{
    		// If the widget params aren't set up, using the plugin defaults
    		$params = $this->init_display( $params );
    		$this->showblock( $params );
    
    		return true;
    	}
    
    	/**
    	*
    	* Where it all comes together
    	*
    	*/
    	function showblock( $params )
    	{
    		?>
    			<div class="bSideItem widget_core_coll_category_list">
    				<input name="submit" class="submit" value="Get selection" type="submit">
    				</form>
    			</div>
    		<?php
    	}
    }
    
    /**
     *
     * Version 0.1.0: 2008-04-19 - Initial release
     *
     */
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic