Creating a Joomla module | Joomla 3.x extension development crash course.

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)"

You have no rights to post comments

Enjoy best web development services at an affordable price. Looking forward to build a good relationship and serve you better...

Copyright © 2017. All rights reserved.