<? php
// no direct access
defined ('_ JEXEC') or die ('Direct Access to this location is not allowed.');
// include the helper file
require_once (dirname (__ FILE __). DS.'helper.php ');
// get a parameter from the module configuration
$ userCount = $ params-> get ('usercount');
// get the items to display from the helper
$ items = ModMyHelper :: getItems ($ userCount);
// include the template for display
require (JModuleHelper :: getLayoutPath ('mod_my'));
?>
<? xml version = "1.0" encoding = "utf-8"?>
<install type = "module" version = "1.5.0">
<! - Name of the Module ->
<module> My Module </ name>
<! - Name of the Author ->
<author> Nick </ author>
<! - Version Date of the Module ->
<creationDate> 2009-03-30 </ creationDate>
<! - Copyright information ->
<copyright> Copyright </ copyright>
<! - License Information ->
<license> GPL 2.0 </ license>
<! - Author's email address ->
<authorEmail> info@info.com </ authorEmail>
<! - Author's website ->
<authorUrl> www..com </ authorUrl>
<! - Module version number ->
<version> 1.0.0 </ version>
<! - Description of what the module does ->
<description> Any </ description>
<! - for the module to function ->
<files>
<! - The "module" attribute defines the main controller file ->
<filename module = "mod_my"> mod_my.php </ filename>
<filename> index.html </ filename>
<filename> helper.php </ filename>
<filename> tmpl / default.php </ filename>
<filename> tmpl / index.html </ filename>
</ files>
<! - Optional parameters ->
<params>
<! - parameter for the module table / xhtml display ->
<param name = "moduleclass_sfx" type = "text" default = "" label = "Module Class Suffix" description = "PARAMMODULECLASSSUFFIX" />
<! - just gives us a little room between the previous paramter and the next ->
<param name = "@ spacer" type = "spacer" default = "" label = "" description = "" />
<! - This parameter will display ->
<param name = "usercount" type = "text" default = "5" label = "Number of users" description = "Specify the number of users" />
</ params>
</ install>
<? php
defined ('_ JEXEC') or die ('Direct Access to this location is not allowed.');
class ModMyHelper
{
/ **
* Returns a list of post items
* /
public function getItems ($ userCount)
{
// get a reference to the database
$ db = & JFactory :: getDBO ();
// get a list of $ userCount randomly ordered users
$ query = 'SELECT a.name FROM `#__ users` AS a LIMIT'. $ userCount. '';
$ db-> setQuery ($ query);
$ items = ($ items = $ db-> loadObjectList ())? $ items: array ();
return $ items;
} // end getItems
} // end SimplestForumLatestPostsHelper
?>
<? php defined ('_ JEXEC') or die ('Restricted access'); // no direct access?>
<ul>
<? php foreach ($ items as $ item) {?>
<li>
<? php echo $ item-> name; ?>
</ li>
<? php}?>
</ ul>
Source: https://habr.com/ru/post/56512/
All Articles