簡體   English   中英

在Joomla中傳遞參數! 模

[英]Passing a parameter in a Joomla! module

我正在joomla中創建一個簡單的模塊。 我有一個文件mod_progress.php。

defined( '_JEXEC' ) or die( 'Restricted access' );
// Include the syndicate functions only 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'));

最后一行是這里感興趣的。 我想取變量$ percentValues並傳遞它以在模塊的default.php模板中使用。

在我的default.php中我只有:

<?php echo $percentValues; ?> 

這不起作用。 我得到的錯誤告訴我變量是未定義的。

但是,如果我這樣做:

<?php $percentValues = htmlspecialchars($params->get('percentValues'));
 echo $percentValues; ?>

它工作得很好。 有人可以解釋為什么我不能使用變量嗎?必須有一些我不知道的大事。 使用Joomla! 3.1。

先感謝您。

賈里德

重新排列代碼

defined( '_JEXEC' ) or die( 'Restricted access' );
// Include the syndicate functions only 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' ) );

應該在包含布局之前聲明變量。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM