php - Passing a parameter in a Joomla! module -
i creating simple module in joomla. have file mod_progress.php.
defined( '_jexec' ) or die( 'restricted access' ); // include syndicate functions once require_once( dirname(__file__).'/helper.php' ); require( jmodulehelper::getlayoutpath( 'mod_progress' ) ); $document = jfactory::getdocument(); $document->addstylesheet(juri::base() . 'modules/mod_progress/tmpl/styles.css'); $percentvalues = htmlspecialchars($params->get('percentvalues'));
the last line of interest here. want take variable $percentvalues , pass on use in module's default.php template.
in default.php have is:
<?php echo $percentvalues; ?>
this not work. error tells me variable undefined.
however, if do:
<?php $percentvalues = htmlspecialchars($params->get('percentvalues')); echo $percentvalues; ?>
it works fine. can explain why can't use variable?there must big missing. using joomla! 3.1.
thank in advance.
jared
rearrange code
defined( '_jexec' ) or die( 'restricted access' ); // include syndicate functions once require_once( dirname(__file__).'/helper.php' ); $percentvalues = htmlspecialchars($params->get('percentvalues')); $document = jfactory::getdocument(); $document->addstylesheet(juri::base() . 'modules/mod_progress/tmpl/styles.css'); require( jmodulehelper::getlayoutpath( 'mod_progress' ) );
should declare variable before include layout.
Comments
Post a Comment