Creating a Joomla module

Files to create / Update

Create  mod_breed.xml /modules/mod_breed/mod_breed.xml

Create  mod_breed.php /modules/mod_breed/mod_breed.php

Create  default.php /modules/mod_breed/tmpl/default.php

Create  en-GB.mod_breed.ini  /language/en-GB/en-GB.mod_breed.ini

Create  en-GB.mod_breed.sys.ini  /language/en-GB/en-GB.mod_breed.sys.ini

 

Files Details

 /modules/mod_breed/mod_breed.xml

 <?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="3.1" client="site" method="upgrade">
	<name>BREEDS</name>
	<author>Nohman Habib</author>
	<creationDate>July 2016</creationDate>
	<copyright>Copyright (C) 2005 - 2015 Open Source Matters. All rights reserved.</copyright>
	<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
	<authorUrl>www.codingace.com</authorUrl>
	<version>3.0.0</version>
	<description>BREEDS_MODULE_DESC</description>
	<files>
		<filename module="mod_breed">mod_breed.php</filename>
		<folder>tmpl</folder>
	</files>
	<languages>
		<language tag="en-GB">en-GB.mod_breed.ini</language>
		<language tag="en-GB">en-GB.mod_breed.sys.ini</language>
	</languages>

	<config>
		<fields name="params">
			<fieldset name="basic">


				<field
					name="width"
					type="text"
					default="200"
					class="validate-numeric"
					filter="integer"
					label="MOD_BREED_IMAGE_WIDTH_LABEL"
					description="MOD_BREED_IMAGE_WIDTH_DESC" />


				<field
					name="height"
					type="text"
					default="200"
					class="validate-numeric"
					filter="integer"
					label="MOD_BREED_IMAGE_HEIGHT_LABEL"
					description="MOD_BREED_IMAGE_HEIGHT_DESC" />

			</fieldset>
		</fields>
	</config>
</extension>

/modules/mod_breed/mod_breed.php


<?php

defined('_JEXEC') or die;

$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'), ENT_COMPAT, 'UTF-8');

require JModuleHelper::getLayoutPath('mod_breed', $params->get('layout', 'default'));

/modules/mod_breed/tmpl/default.php

<?php

defined('_JEXEC') or die;

$width      = $params->get('width');
$height    = $params->get('height');

    $query = "SELECT * FROM #__breed_breed ORDER BY rand() LIMIT 1 "; 
    $db = &JFactory::getDBO();
    $db->setQuery($query);
    $rowsc = $db->loadObjectList();
    foreach($rowsc as $rowc) 
{ 
 $breedname=$rowc->breedname;   $pic=$rowc->pic;   $shortdesc=$rowc->shortdesc;
 }

?>

<h4><?php echo $breedname; ?></h4>

<img src="<?php echo JRoute::_(JUri::root()); ?>/components/com_breed/breedpic/<?php echo $pic; ?>" width="<?php echo $width; ?>px" height="<?php echo $height; ?>px">

<p>
<?php echo $shortdesc; ?>
</p>

/language/en-GB/en-GB.mod_breed.sys.ini

BREEDS="Breeds"

 /language/en-GB/en-GB.mod_breed.ini

BREEDS="Breeds"
BREEDS_MODULE_DESC="Displays random breeds from breeds component"
MOD_BREED_IMAGE_WIDTH_LABEL="Image width (px)"
MOD_BREED_IMAGE_HEIGHT_LABEL="Image height (px)"

Add a Comment

Your email address will not be published. Required fields are marked *

ABOUT CODINGACE

My name is Nohman Habib and I am a web developer with over 10 years of experience, programming in Joomla, Wordpress, WHMCS, vTiger and Hybrid Apps. My plan to start codingace.com is to share my experience and expertise with others. Here my basic area of focus is to post tutorials primarily on Joomla development, HTML5, CSS3 and PHP.

Nohman Habib

CEO: codingace.com

Request a Quote









PHP Code Snippets Powered By : XYZScripts.com