NP_CropExtended

This plugin crop extended body after x number of words.

General Plugin info
Author: Roberto Bolli
Current Version: 0.1
Download: -
Code: code
Demo: -
Forum Thread: -

This plugin shows a cropped “extended body” in a nucleus page. This can be usefull when you want to show an excerpt of the extended_body of an article and dont want alter/rewrite the structure of your articles. The plugin creates a new template variable called <%CropExtended%> that cut the extended body after the number of words that you can specify in the plugin options. The script needs a lot of improvements to correctly works (eg: in the current version HTML tag will be truncated…).

The code is based on admun's plugin NP_AutoExtended.

Install & Use

  • Copy and paste the code below into a file called NP_CropExtended.php (or download it from my site).
  • Upload the file into the nucleus plugin directory,
  • Then install or update the subscription list.
  • Include <%CropExtended%> in your template where you want the output to appear.

Code

<?php
 
/*
************************************************
Use <%CropExtended%> in a template to show a
little portion of the extended part of an
article in a page. Use plugin option to set how
many words show in the extended cropped part.
 
Roberto Bolli
http://www.rbnet.it/
************************************************
*/
 
class NP_CropExtended extends NucleusPlugin {
 
  function getMinNucleusVersion() { return '250'; }
 
  function getName() { return 'Crop Extended Body';    }
 
  function getAuthor() { return 'Roberto Bolli';    }
 
  function getURL() { return 'http://www.rbnet.it/'; }
 
  function getVersion() { return '0.1'; }
 
  function getDescription() { return 'This plugin crop extended body after x number of words. Based on the Admund\'s NP_AutoExtended plugin: http://forum.nucleuscms.org/viewtopic.php?t=3625'; }
 
  function install() {
    $this->createOption('nWords','Number of the words after cropping extended body','text','20');
  }
 
  function supportsFeature($what) {
    switch($what) {
      case 'SqlTablePrefix':
        return 1;
      default:
        return 0;
    }
  }
 
  function doTemplateVar(&$data) {
 
   $croppedmore = $data->more;
   $words = explode(' ', $croppedmore);
 
      if (sizeof($words) > $this->getOption('nWords')) {
         $i = 1;
         $croppedmore = '';
         foreach ($words as $word) {
            if ($i <= $this->getOption('nWords')) {
               $croppedmore = $croppedmore . $word . ' ';
            }
         $i++;
         }
 
         $croppedmore = $croppedmore . '�';
     }
     echo $croppedmore;
  }
}
?>


- RbNet
- http://www.rbnet.it/

Plugin review

NP_CropExtended 0.1 works with Nucleus CMS version 3.31 - 2007-11-02 ftruscot

cropextended.txt · Last modified: 2007/11/03 03:04 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki