How to include PHP commands in Section/Content Description (for Joomla 1.5.x)? |
| Written by kksou | ||
| Tuesday, 22 April 2008 | ||
|
The DirectPHP plugin which I released in March 2008 allows you to include PHP commands in content items only. This article shows you how to include PHP commands right inside Section/Category description. You can see a live example here. It seems that starting Joomla v1.5.3, the section/category description now gets processed by the content plugins by default! So if you're using Joomla v1.5.3 and above, you no longer need to modify the joomla core to achieve this. That is, you can skip steps 3 and 4 below, but you still need to install the plugin and follow the rest of the steps. Solutions
Note: If you've already installed the plugin loadmodule for Section/Category Description, you can skip this step.
class ContentViewCategory extends ContentView
{
function display($tpl = null)
{
global $mainframe, $option;
// Initialize some variables
$user =& JFactory::getUser();
$uri =& JFactory::getURI();
$document =& JFactory::getDocument();
$pathway =& $mainframe->getPathway();
$category =& $this->get('Category');
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
$results = $dispatcher->trigger('onBeforeDisplayTitle', array (& $category));
// Get the menu item object
$menus = &JSite::getMenu();
$menu = $menus->getActive();
class ContentViewSection extends ContentView
{
function display($tpl = null)
{
global $mainframe, $option;
// Initialize some variables
$user =& JFactory::getUser();
$document =& JFactory::getDocument();
$section =& $this->get('Section');
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
$results = $dispatcher->trigger('onBeforeDisplayTitle', array (& $section));
// Get the page/component configuration
$params = &$mainframe->getParams();
// Request variables
$limit = JRequest::getVar('limit', $params->get('display_num'), '', 'int');
$limitstart = JRequest::getVar('limitstart', 0, '', 'int');
class ContentViewSection extends ContentView
{
function display($tpl = null)
{
.
.
.
//add alternate feed link
if($params->get('show_feed_link', 1) == 1)
{
$link = '&format=feed&limitstart=';
$attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
$document->addHeadLink(JRoute::_($link.'&type=rss'),
'alternate', 'rel', $attribs);
$attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
$document->addHeadLink(JRoute::_($link.'&type=atom'),
'alternate', 'rel', $attribs);
}
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
for($i = 0; $i < count($categories); $i++)
{
$category =& $categories[$i];
$category->link = JRoute::_('index.php?view=category&id='.
$category->slug);
$results=$dispatcher->trigger('onBeforeDisplayTitle', array(&$category));
}
if ($total == 0) {
$params->set('show_categories', false);
}
Current date and time is: <?php echo date('Y-m-d H:i:s');?>
You should see the current date and time displayed in the section or category description. Very Important Note about the Editor!!!If you're using the default TinyMCE WYSIWYG Editor, you will face one problem. When you first enter PHP commands into the editor, encapsulated in <?php ... ?>, everything's ok. But as soon as you click the save button, all your PHP commands will disappear! Don't worry. They are all still there. But the problem is, unlike content items, the default TinyMCE WYSIWYG Editor refuses to display anything in tags. There are two solutions to this.
User reviews Average user ratings: 4.0 (from 2 users) Note: You have to be a registered member to leave a comment. Free registration here. |
||
| < Prev | Next > |
|---|
Joomla 1.0 Articles
- How to create a module with DirectPHP plugin?
- How to include modules in Content item?
- How to include modules in Section/Content Description
- How to include PHP commands in Section/Content Description
- How to make plugins process Section/Category descriptions
- Include Code Listing plugin - More Tips and Techniques
- How to have DirectPHP plugin process RSS feed?
- How to have the plugins processed when genrating PDF documents of content items?
- How to have DirectPHP commands processed in Joomla search?
Joomla 1.5 Articles
- How to create a module with DirectPHP plugin?
- How to include modules in Content item?
- How to include modules in Section/Content Description
- How to include PHP commands in Section/Content Description
- How to make plugins process Section/Category descriptions
- Include Code Listing plugin - More Tips and Techniques
- How to have DirectPHP plugin process RSS feed?
- How to have the plugins processed when genrating PDF documents of content items?
- How to have DirectPHP commands processed in Joomla search?
Joomla Plugins
Joomla Components
Joomla Gadgets
- Google Image Search
- Google News Search
- Wikipedia Search
- Google Book Search
- Google Video Search
- Google Currency Converter - AJAX version
- Yahoo Currency Converter - AJAX version
- Yahoo Stock Quote (AJAX module version)
- Yahoo Stock Quote (AJAX component/ module version)
- googleSearch_cse component
- googleSearch_cse module
- googleMaps plugin








September 11, 2008 5:47pm
in joomla 1.5.6, the script view.html.php, in /components/com_content/views/section had changed. So how I put the additional lines?
September 11, 2008 7:27pm
Please refer to the following post:
Re: How to allow plugins/mambots to work inside of Section/Categ
It seems that starting v1.5.3, the section/category description now gets processed by the content plugins by default! You no longer need to modify the joomla core to achieve this.
Give it a try, and let me know if it works on Joomla 1.5.6.
Regards,
/kksou