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.
<?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; } } ?>
NP_CropExtended 0.1 works with Nucleus CMS version 3.31 - 2007-11-02 ftruscot