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?
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 create a module with DirectPHP plugin (for Joomla 1.5.x) |
| Written by kksou | ||
| Thursday, 27 March 2008 | ||
|
You can easily create Joomla modules using the DirectPHP plugin. In this article, I will show you how to create a module similar to the Most Popular module (mod_mostread) that comes with the standard Joomla installation. Our version of "Most Popular" module has one additional enhancement: it will list the total number of hits for each listing as shown below:
Note: the steps below are for Joomla 1.5.x. If you're using Joomla 1.0.x, please refer to How to create a module with DirectPHP plugin (for Joomla 1.0.x). The steps are easier for Joomla 1.0.x. Here are the steps to create a Joomla module
<?php
global $mainframe;
$db =& JFactory::getDBO();
$query = "SELECT * FROM #__content ORDER BY hits DESC limit 0,10";
$db->setQuery( $query, 0, $count );
$rows = $db->loadObjectList();
echo '<ul>';
foreach($rows as $row) {
echo "<li>$row->title ($row->hits views)</li>";
}
echo '</li>';
?>
Note: Please make sure you're only doing this on your development machine. It's too dangerous to do this on a live machine, unless you're the only one managing your website.
Of course the above code is extremely simplified. I just want to show you that creating a Joomla module using DirectPHP plugin is simple and straightforward. If you want, you can refer to mod_mostread.php and put in a more complex database query that checks access control, whether it's published or not, and adds a link to the article, etc. Creating More ModulesTo create more modules, you do not need to install more copies of "CustomContent". Following from the above example, from the Module Manager, check the module "Most Popular v2" , and then select "Copy" from the menu on the top-right as shown below (the third one from the left):
You will see another module called "Copy of Most Popular v2" appearing above or below "Most Popular v2". Click on that module and then select another article containing a different PHP code. You have now a new module! User reviews Average user ratings: 3.0 (from 2 users)Note: You have to be a registered member to leave a comment. Free registration here. |
||
| < Prev | Next > |
|---|









3.0 (from 2 users)
April 08, 2008 7:46pm
can not find directphp.
causes the whole tutorial to fall apart.
April 08, 2008 7:56pm
Please click the "DirectPHP plugin" link in the very first paragraph.
Regards,
/kksou