Recent Topics

1 Jun 13, 2008 17:04    

I've created a simple plugin that sums up a list of article titles. Very usefull if you display a lot of post on your homepage, and want to start with a simple overview.

I added some features that allows to enable / disable the plugin via the plugin settings, and gives you control over on only displaying the plugin on the home-page, an article page or both or none. Whatever you situation likes.

Just create a file called
_article_titles.plugin.php
And add the following code in it.

<?php
/**
 * This file implements the Article Titles plugin.
 *
 * @copyright (c)2008 by Julien Moorrees - {@link http://fplanque.net/}
 *
 * {@internal License choice
 * - If you have received this file as part of a package, please find the license.txt file in
 *   the same folder or the closest folder above for complete license terms.
 * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
 *   then you must choose one of the following licenses before using the file:
 *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
 *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
 * }}
 *
 * {@internal Open Source relicensing agreement:
 * Daniel HAHLER grants Francois PLANQUE the right to license
 * Daniel HAHLER's contributions to this file and the b2evolution project
 * under any OSI approved OSS license (http://www.opensource.org/licenses/).
 * }}
 *
 * @package plugins
 *
 * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
 * @author Julien Moorrees
 *
 * @version $Id: _advert_banner.plugin.php,v 1.0 2008/06/13 12:35:41 MoorreesJ Exp $
 */
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );


/**
 */
class article_titles_plugin extends Plugin
{
	/**
	 * Variables below MUST be overriden by plugin implementations,
	 * either in the subclass declaration or in the subclass constructor.
	 */

	var $name = 'Article Titles Widget';
	var $code = 'evo_ArticleTitles';
	var $priority = 96;
	var $version = '2.0';
	var $author = 'Julien Moorrees';
	var $group = 'widget';


	/**
	 * Init
	 */
	function PluginInit( & $params )
	{
		$this->short_desc = T_('This skin tag displays a list of the article titles');
		$this->long_desc = T_('Displays a list of article titles');
	}


  /**
   * Get definitions for widget specific editable params
   *
	 * @see Plugin::GetDefaultSettings()
	 * @param local params like 'for_editing' => true
	 */
	function get_widget_param_definitions( $params )
	{
		$r = array(
			'enable' => array(
				'label' => T_('Enable'),
				'note' => T_('Enable this widget.'),
				'type' => 'checkbox',
				'defaultvalue' => true,
			),
			'swhowonhome' => array(
				'label' => T_('Show on homepage'),
				'note' => T_('Show this widget on the homepage'),
				'type' => 'checkbox',
				'defaultvalue' => true,
			),
			'swhowonarticle' => array(
				'label' => T_('Show on Article'),
				'note' => T_('Show this widget on an article page'),
				'type' => 'checkbox',
				'defaultvalue' => false,
			),
			'title' => array(
				'label' => 'Block title',
				'size' => 60,
			),
			
		);
		return $r;
	}


	/**
	 * Event handler: SkinTag (widget)
	 *
	 * @param array Associative array of parameters.
	 * @return boolean did we display?
	 */
	function SkinTag( $params )
	{
		global $generating_static, $Plugins,$MainList;


		if( empty($MainList) )
		{
			return false;
		}

		if( ! empty($generating_static) || $Plugins->trigger_event_first_true('CacheIsCollectingContent') )
		{ // We're not generating static pages nor is a caching plugin collecting the content, so we can display this block
			return false;
		}

		if ($params['enable']==false) {
			return false;
		}
		
		if( isset($MainList) && $MainList->result_num_rows > 1 )  {
			// We are on the homepage
			if ($params['swhowonhome']==false) {
				return false;
			}
		}
		else {
			// We are on an article
			if ($params['swhowonarticle']==false) {
				return false;
			}
		}
		
		echo $params['block_start'];

		echo $params['block_title_start'];
		echo $params['title'];
		echo $params['block_title_end'];

		//Do your magic here

		// -------------------- PREV/NEXT PAGE LINKS (POST LIST MODE) --------------------
		echo $MainList->page_links( array(
				'block_start' => '',
				'block_end' => '',
				'block_single' => '',
				'links_format' => '#',
				'page_url' => '', // All generated links will refer to the current page
				'prev_text' => '&lt;&lt;',
				'next_text' => '&gt;&gt;',
				'no_prev_text' => '',
				'no_next_text' => '',
				'list_prev_text' => '...',
				'list_next_text' => '...',
				'list_span' => 4,
				'scroll_list_range' => 5,
			)
		);
		echo "<br />";
		// ------------------------- END OF PREV/NEXT PAGE LINKS -------------------------

		$MainList->current_idx = 0;
		while( $Item = $MainList->get_item() )
		{
			?>
				<a href="<?php $Item->permanent_url() ?>" title="<?php echo T_('Permanent link to full entry') ?>" ><?php $Item->title(); ?></a><br />
			<?php 
		}
		echo $params['block_end'];
		$MainList->current_idx = 0;
		return true;
	}
}
?>


Upload to plugin directory and install as normally. You can now add the list as a widget.

Enjoy!

3 Jun 16, 2008 13:59

Fixed a little bug that showed an error on some pages like the contact page.

4 Jun 18, 2008 11:02

to install, produces this error:

Warning: Cannot modify header information - headers already sent by (output started at /home/mysite/public_html/plugins/_article_titles.plugin.php:2) in /home/mysite/public_html/skins_adm/_html_header.inc.php on line 40

5 Jun 18, 2008 11:16

Delete the whitespace before the opening <?php tag ;)

¥

6 Jun 18, 2008 11:49

hello ¥åßßå

these are the first lines of _html_header.inc.php.
Delete the whitespace before the second opening <? Php tag.
follows the error

<?php
/**
 * This file displays the first part of the page menu (before the page title).
 *
 * This file is part of the evoCore framework - {@link http://evocore.net/}
 * See also {@link http://sourceforge.net/projects/evocms/}.
 *
 * @copyright (c)2003-2008 by Francois PLANQUE - {@link http://fplanque.net/}
 * Parts of this file are copyright (c)2005-2006 by PROGIDISTRI - {@link http://progidistri.com/}.
 *
 * {@internal License choice
 * - If you have received this file as part of a package, please find the license.txt file in
 *   the same folder or the closest folder above for complete license terms.
 * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
 *   then you must choose one of the following licenses before using the file:
 *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
 *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
 * }}
 *
 * {@internal Open Source relicensing agreement:
 * PROGIDISTRI S.A.S. grants Francois PLANQUE the right to license
 * PROGIDISTRI S.A.S.'s contributions to this file and the b2evolution project
 * under any OSI approved OSS license (http://www.opensource.org/licenses/).
 * }}
 *
 * @package admin
 *
 * @author blueyed
 * @author fplanque
 * @author mbruneau: Marc BRUNEAU / PROGIDISTRI
 *
 * @version $Id: _html_header.inc.php,v 1.6 2008/02/08 22:24:46 fplanque Exp $
 */
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );

global $io_charset, $rsc_url, $UserSettings, $Debuglog, $Plugins, $generating_static;
global $month, $month_abbrev, $weekday, $weekday_abbrev; /* for localized calendar */
global $debug, $Hit;

 => header( 'Content-type: text/html; charset='.$io_charset );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="<?php locale_lang() ?>" lang="<?php locale_lang() ?>">
<head>
	<title><?php echo $this->get_html_title(); ?></title>
	<meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />
<?php
	global $rsc_path, $rsc_url, $htsrv_url;

7 Jun 18, 2008 11:57

Don't access this file directly, but install it as a plugin. You can then add a widget to your template. Don't include this file in your template.

8 Jun 18, 2008 12:01

participacion wrote:

Warning: Cannot modify header information - headers already sent by (output started at /home/mysite/public_html/plugins/_article_titles.plugin.php:2) in /home/mysite/public_html/skins_adm/_html_header.inc.php on line 40

Check that file ;)

¥

9 Jun 18, 2008 12:08

I removed the whitespace in that file just now.

11 Jun 18, 2008 13:05

Copy and paste your plugin code as it is now, from notepad into here ( between [php][/php] tags )

¥

12 Jun 18, 2008 13:45

Ok, i editted the first message with using PHP tags. Is it alright now?

13 Jun 18, 2008 14:00

Sorry nims, that was directed at participation, if they still have the error then they still have whitespace in the file

¥

14 Jun 18, 2008 14:07

Then I don't understand if my plugin has an error, or that it is correct. I am using it myself, and have not got any problems at all.

15 Jun 18, 2008 14:26

Hi nims & participation,

Participation made a copy/paste error, so he unintendedly entered whitespace (carriage return "Enter" or space) before the first <?php resulting in the error mentioned.
Probably you could make a downloadable zip of the plugin to avoid confusion.

Good luck

16 Jun 18, 2008 14:32

hello Afwas
Here is the code

<?php 
/** 
 * This file implements the Article Titles plugin. 
 * 
 * @copyright (c)2008 by Julien Moorrees - {@link http://fplanque.net/} 
 * 
 * {@internal License choice 
 * - If you have received this file as part of a package, please find the license.txt file in 
 *   the same folder or the closest folder above for complete license terms. 
 * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/) 
 *   then you must choose one of the following licenses before using the file: 
 *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php 
 *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php 
 * }} 
 * 
 * {@internal Open Source relicensing agreement: 
 * Daniel HAHLER grants Francois PLANQUE the right to license 
 * Daniel HAHLER's contributions to this file and the b2evolution project 
 * under any OSI approved OSS license (http://www.opensource.org/licenses/). 
 * }} 
 * 
 * @package plugins 
 * 
 * {@internal Below is a list of authors who have contributed to design/coding of this file: }} 
 * @author Julien Moorrees 
 * 
 * @version $Id: _advert_banner.plugin.php,v 1.0 2008/06/13 12:35:41 MoorreesJ Exp $ 
 */ 
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); 


/** 
 */ 
class article_titles_plugin extends Plugin 
{ 
   /** 
    * Variables below MUST be overriden by plugin implementations, 
    * either in the subclass declaration or in the subclass constructor. 
    */ 

   var $name = 'Article Titles Widget'; 
   var $code = 'evo_ArticleTitles'; 
   var $priority = 96; 
   var $version = '2.0'; 
   var $author = 'Julien Moorrees'; 
   var $group = 'widget'; 


   /** 
    * Init 
    */ 
   function PluginInit( & $params ) 
   { 
      $this->short_desc = T_('This skin tag displays a list of the article titles'); 
      $this->long_desc = T_('Displays a list of article titles'); 
   } 


  /** 
   * Get definitions for widget specific editable params 
   * 
    * @see Plugin::GetDefaultSettings() 
    * @param local params like 'for_editing' => true 
    */ 
   function get_widget_param_definitions( $params ) 
   { 
      $r = array( 
         'enable' => array( 
            'label' => T_('Enable'), 
            'note' => T_('Enable this widget.'), 
            'type' => 'checkbox', 
            'defaultvalue' => true, 
         ), 
         'swhowonhome' => array( 
            'label' => T_('Show on homepage'), 
            'note' => T_('Show this widget on the homepage'), 
            'type' => 'checkbox', 
            'defaultvalue' => true, 
         ), 
         'swhowonarticle' => array( 
            'label' => T_('Show on Article'), 
            'note' => T_('Show this widget on an article page'), 
            'type' => 'checkbox', 
            'defaultvalue' => false, 
         ), 
         'title' => array( 
            'label' => 'Block title', 
            'size' => 60, 
         ), 
          
      ); 
      return $r; 
   } 


   /** 
    * Event handler: SkinTag (widget) 
    * 
    * @param array Associative array of parameters. 
    * @return boolean did we display? 
    */ 
   function SkinTag( $params ) 
   { 
      global $generating_static, $Plugins,$MainList; 


      if( empty($MainList) ) 
      { 
         return false; 
      } 

      if( ! empty($generating_static) || $Plugins->trigger_event_first_true('CacheIsCollectingContent') ) 
      { // We're not generating static pages nor is a caching plugin collecting the content, so we can display this block 
         return false; 
      } 

      if ($params['enable']==false) { 
         return false; 
      } 
       
      if( isset($MainList) && $MainList->result_num_rows > 1 )  { 
         // We are on the homepage 
         if ($params['swhowonhome']==false) { 
            return false; 
         } 
      } 
      else { 
         // We are on an article 
         if ($params['swhowonarticle']==false) { 
            return false; 
         } 
      } 
       
      echo $params['block_start']; 

      echo $params['block_title_start']; 
      echo $params['title']; 
      echo $params['block_title_end']; 

      //Do your magic here 

      // -------------------- PREV/NEXT PAGE LINKS (POST LIST MODE) -------------------- 
      echo $MainList->page_links( array( 
            'block_start' => '', 
            'block_end' => '', 
            'block_single' => '', 
            'links_format' => '#', 
            'page_url' => '', // All generated links will refer to the current page 
            'prev_text' => '&lt;&lt;', 
            'next_text' => '&gt;&gt;', 
            'no_prev_text' => '', 
            'no_next_text' => '', 
            'list_prev_text' => '...', 
            'list_next_text' => '...', 
            'list_span' => 4, 
            'scroll_list_range' => 5, 
         ) 
      ); 
      echo "<br />"; 
      // ------------------------- END OF PREV/NEXT PAGE LINKS ------------------------- 

      $MainList->current_idx = 0; 
      while( $Item = $MainList->get_item() ) 
      { 
         ?> 
            <a href="<?php $Item->permanent_url() ?>" title="<?php echo T_('Permanent link to full entry') ?>" ><?php $Item->title(); ?></a><br /> 
         <?php 
      } 
      echo $params['block_end']; 
      $MainList->current_idx = 0; 
      return true; 
   } 
} 
?> 

17 Jun 18, 2008 14:41

hi participation,

This shouldn't give an error. Do use a plain text editor when you save the file.

Good luck

18 Jun 18, 2008 14:47

I created the file _article_titles.plugin.php with notepad.

installing the plug, this new error occurs:

Warning: Cannot modify header information - headers already sent by (output started at /home/podersoc/public_html/plugins/_article_titles.plugin.php:174) in /home/podersoc/public_html/skins_adm/_html_header.inc.php on line 40

Here is the code

<?php 
/** 
 * This file implements the Article Titles plugin. 
 * 
 * @copyright (c)2008 by Julien Moorrees - {@link http://fplanque.net/} 
 * 
 * {@internal License choice 
 * - If you have received this file as part of a package, please find the license.txt file in 
 *   the same folder or the closest folder above for complete license terms. 
 * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/) 
 *   then you must choose one of the following licenses before using the file: 
 *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php 
 *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php 
 * }} 
 * 
 * {@internal Open Source relicensing agreement: 
 * Daniel HAHLER grants Francois PLANQUE the right to license 
 * Daniel HAHLER's contributions to this file and the b2evolution project 
 * under any OSI approved OSS license (http://www.opensource.org/licenses/). 
 * }} 
 * 
 * @package plugins 
 * 
 * {@internal Below is a list of authors who have contributed to design/coding of this file: }} 
 * @author Julien Moorrees 
 * 
 * @version $Id: _advert_banner.plugin.php,v 1.0 2008/06/13 12:35:41 MoorreesJ Exp $ 
 */ 
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); 


/** 
 */ 
class article_titles_plugin extends Plugin 
{ 
    /** 
     * Variables below MUST be overriden by plugin implementations, 
     * either in the subclass declaration or in the subclass constructor. 
     */ 

    var $name = 'Article Titles Widget'; 
    var $code = 'evo_ArticleTitles'; 
    var $priority = 96; 
    var $version = '2.0'; 
    var $author = 'Julien Moorrees'; 
    var $group = 'widget'; 


    /** 
     * Init 
     */ 
    function PluginInit( & $params ) 
    { 
        $this->short_desc = T_('This skin tag displays a list of the article titles'); 
        $this->long_desc = T_('Displays a list of article titles'); 
    } 


  /** 
   * Get definitions for widget specific editable params 
   * 
     * @see Plugin::GetDefaultSettings() 
     * @param local params like 'for_editing' => true 
     */ 
    function get_widget_param_definitions( $params ) 
    { 
        $r = array( 
            'enable' => array( 
                'label' => T_('Enable'), 
                'note' => T_('Enable this widget.'), 
                'type' => 'checkbox', 
                'defaultvalue' => true, 
            ), 
            'swhowonhome' => array( 
                'label' => T_('Show on homepage'), 
                'note' => T_('Show this widget on the homepage'), 
                'type' => 'checkbox', 
                'defaultvalue' => true, 
            ), 
            'swhowonarticle' => array( 
                'label' => T_('Show on Article'), 
                'note' => T_('Show this widget on an article page'), 
                'type' => 'checkbox', 
                'defaultvalue' => false, 
            ), 
            'title' => array( 
                'label' => 'Block title', 
                'size' => 60, 
            ), 
             
        ); 
        return $r; 
    } 


    /** 
     * Event handler: SkinTag (widget) 
     * 
     * @param array Associative array of parameters. 
     * @return boolean did we display? 
     */ 
    function SkinTag( $params ) 
    { 
        global $generating_static, $Plugins,$MainList; 


        if( empty($MainList) ) 
        { 
            return false; 
        } 

        if( ! empty($generating_static) || $Plugins->trigger_event_first_true('CacheIsCollectingContent') ) 
        { // We're not generating static pages nor is a caching plugin collecting the content, so we can display this block 
            return false; 
        } 

        if ($params['enable']==false) { 
            return false; 
        } 
         
        if( isset($MainList) && $MainList->result_num_rows > 1 )  { 
            // We are on the homepage 
            if ($params['swhowonhome']==false) { 
                return false; 
            } 
        } 
        else { 
            // We are on an article 
            if ($params['swhowonarticle']==false) { 
                return false; 
            } 
        } 
         
        echo $params['block_start']; 

        echo $params['block_title_start']; 
        echo $params['title']; 
        echo $params['block_title_end']; 

        //Do your magic here 

        // -------------------- PREV/NEXT PAGE LINKS (POST LIST MODE) -------------------- 
        echo $MainList->page_links( array( 
                'block_start' => '', 
                'block_end' => '', 
                'block_single' => '', 
                'links_format' => '#', 
                'page_url' => '', // All generated links will refer to the current page 
                'prev_text' => '&lt;&lt;', 
                'next_text' => '&gt;&gt;', 
                'no_prev_text' => '', 
                'no_next_text' => '', 
                'list_prev_text' => '...', 
                'list_next_text' => '...', 
                'list_span' => 4, 
                'scroll_list_range' => 5, 
            ) 
        ); 
        echo "<br />"; 
        // ------------------------- END OF PREV/NEXT PAGE LINKS ------------------------- 

        $MainList->current_idx = 0; 
        while( $Item = $MainList->get_item() ) 
        { 
            ?> 
                <a href="<?php $Item->permanent_url() ?>" title="<?php echo T_('Permanent link to full entry') ?>" ><?php $Item->title(); ?></a><br /> 
            <?php  
        } 
        echo $params['block_end']; 
        $MainList->current_idx = 0; 
        return true; 
    } 
} 
?> 

19 Jun 18, 2008 14:48

Delete any whitespace *after* the closing ?>

20 Jun 18, 2008 14:54

I think you shouldn't use notepad, but a texteditor that dashes the CR/LF chars and just uses the linux format.
Ultraedit for example has an option to convert the file to linux format. Also some ftp-clients have the option to upload the file as text. Maybe that can "fix" your problem.

21 Jun 18, 2008 15:36

Afwas wrote:

Delete any whitespace *after* the closing ?>

Afwas
thanks ...
ready ...

nims
Thanks for the plugin

22 Jan 27, 2009 19:01

isnt that the same as lates t posts?

23 Jan 27, 2009 22:01

Yes it is. But it's a little more simple: it only shows the title list, and the paging numbers.

24 Jan 30, 2009 05:16

Well, I tried this plugin--copy & paste into dreamweaver file, nothing but code in first posting this thread.

Got this on attempted installation into plugins:

Parse error: syntax error, unexpected '}' in /home/wordturn/public_html/healthygreenpaint/plugins/_article_titles.plugin.php on line 167

Ideas????

25 Feb 07, 2009 17:34

This plugin is virtually unusable when someone tries to copy/paste it from these forums. I kinda know what I'm doing with grabbing someone else's code, and I keep getting whitespace that simply doesn't show up here.

nims you really need to make a downloadable .zip of this thing else it will always cause the troubles that both participation and martha have reported.

Also please add a readme.html file so users will know what it will do and what they can do with it. Adding a readme is the crappiest ugliest longest WORST part of writing a plugin, but it really does help your users.

BOTTOM LINE: anyone trying to copy/paste this out of one the forums will have to edit out a space before the very first <?php and after the very last ?>

26 Jul 16, 2011 22:50

I do not agree with that.
I copied he code and pasted it in nano (Linux editor).
My editor wrapped some comment lines, but after repairing the plugin worked at once.
Now I have this widget, I only do not understand how to put it above the content on the main page. In the blog setting I can add the widget to the menus or header etc. but how do I generate a main index page with this?

27 Jul 16, 2011 23:21

@joopsiroop
This is a very old thread. You don't need this plugin if you are using b2evolution v3 or 4. Just go to Blog settings > Widgets and add a Post list widget


Form is loading...