Joomla模块没有获取参数

时间:2016-04-05 09:13:22

标签: php joomla

我有一个模块,我想在“标题”中添加“short_description”。 我添加了参数,但它不起作用。我做错了什么? module here in right possition

模块代码:

<?php
/**
 * @package     SP LMS
 * @subpackage  mod_splmscourses
 *
 * @copyright   Copyright (C) 2010 - 2015 JoomShaper. All rights reserved.
 * @license     GNU General Public License version 2 or later.
 */

defined('_JEXEC') or die;
jimport( 'joomla.filesystem.file' );

//Joomla Component Helper & Get LMS Params
jimport('joomla.application.component.helper');
$splmsparams = JComponentHelper::getParams('com_splms');

//Get Currency
$currency = explode(':', $splmsparams->get('currency', 'USD:$'));
$currency =  $currency[1];

// Get image thumb
$thumb_size = strtolower($splmsparams->get('course_thumbnail_small', '100X60'));


?>

<div class="mod-splms-courses <?php echo $moduleclass_sfx; ?>">

    <ul class="splms-courses-list">
        <?php foreach ($items as $item) { ?>
        <?php $item->price = ($item->price == 0) ? JText::_('MOD_SPLMS_COURSES_FREE') : JText::_($currency) . $item->price; ?>
        <?php $item->short_description; ?>
        <li class="mod-splms-course clearfix">
            <a href="<?php echo $item->url; ?>">
                <?php
                $filename = basename($item->image);
                $path = JPATH_BASE .'/'. dirname($item->image) . '/thumbs/' . JFile::stripExt($filename) . '_' . $thumb_size . '.' . JFile::getExt($filename);
                $src = JURI::base(true) . '/' . dirname($item->image) . '/thumbs/' . JFile::stripExt($filename) . '_' . $thumb_size . '.' . JFile::getExt($filename);

                if(JFile::exists($path)) {
                    $thumb = $src;
                } else {
                    $thumb = $item->image;
                }
                ?>
                <a href="<?php echo $item->url; ?>">
                    <img src="<?php echo $thumb; ?>" class="splms-course-img splms-img-responsive" alt="<?php echo $item->title; ?>">
                </a>
            </a>

            <strong class="splms-course-title">
                <a href="<?php echo $item->url; ?>" class="splms-course-title"><?php echo $item->title; ?></a>
                <p>
                    <?php echo $item->price; ?>
                    <?php echo $item->short_description; ?>
                </p>
            </strong>

        </li>
        <?php } ?>
    </ul>
</div>

<?php

我在两个地方只添加了一行:“<?php echo $item->short_description; ?>” 一个位于<ul>,一个位于<p>

1 个答案:

答案 0 :(得分:0)

如果您已将 short_description 添加为参数(在模块的xml文件中),则可以使用以下代码检索它:$params->get('short_description','');