Joomla 组件:视图:从字段中获取值



我是Joomla的新手,尤其是组件开发。无论如何,这是我的问题:

站点\视图\普通库\TMPL\默认.xml

<?xml version="1.0" encoding="utf-8"?>
<metadata>
    <layout title="COM_PLAINGALLERY_PLAINGALLERY_VIEW_DEFAULT_TITLE">
        <message>
            <![CDATA[COM_PLAINGALLERY_PLAINGALLERY_VIEW_DEFAULT_DESC]]>
        </message>
    </layout>
    <fields name="request"
        addfieldpath="/administrator/components/com_plaingallery/models/fields">
        <fieldset name="request">
            <field name="galleryFolder" type="folderlist" default="" recursive="true"
                label="Select a folder" directory="images" filter="" exclude="" width="300"
                hide_none="true" hide_default="true" stripext="" />
        </fieldset>
    </fields>
</metadata>
站点\视图\

普通库\视图.html.php

<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla view library
jimport('joomla.application.component.view');
/**
 * HTML View class for the PlainGallery Component
 */
class PlainGalleryViewPlainGallery extends JViewLegacy
{
    // Overwriting JView display method
    function display($tpl = null)
    {
        // Assign data to the view      
        $this->msg = 'I am new to Joomla';
        // Display the view
        parent::display($tpl);
    }
}

我的问题是:如何从用户在菜单配置中提供的字段[name="galleryFolder"]访问值?

感谢您的帮助!我真的很感激。

此参数位于菜单项的查询变量中。

例如,您可以尝试以下方法:

    $app = JFactory::getApplication();
    /* Default Page fallback*/
    $active = $app->getMenu()->getActive();
    if (NULL == $active) {
        $active = $app->getMenu()->getDefault();
    }
    if ( isset($active->query['galleryFolder']) ) {
        $galleryFolder = $active->query['galleryFolder'];
    }

最新更新