Joomla组件类别开发

时间:2016-08-10 16:21:03

标签: components joomla3.5

我跟随joomla"开发MVC组件"记录到步骤15-"添加ACL"

IQueryable<Derived> yourQuery = ...;
return yourQuery.SelectTo<Base>();

一切正常,

但我没有看到有关创建前端类别视图的任何内容,所以我添加了一个新视图&#34;类别&#34;,这是我的代码:

在admin fields文件夹中,我创建了一个hellocategory.php 大多数代码与helloword相同,只需更改

Link - https://docs.joomla.org/J3.x:Developing_an_MVC_Component/Adding_ACL

view.html.php

protected $type = 'HelloCategory';

/**
 * Method to get a list of options for a list input.
 *
 * @return  array  An array of JHtml options.
 */
protected function getOptions()
{
    $db    = JFactory::getDBO();
    $query = $db->getQuery(true);
    // custom
    $query->select('#__categories.id as id,#__categories.title as category,#__categories.extension as exten');
    $query->from('#__categories');  
    $query->where($db->quoteName('extension') . ' LIKE '. $db->quote('com_helloworld'));
    // end custom
    $db->setQuery((string) $query);
    $messages = $db->loadObjectList();
    $options  = array();

default.xml中

class HelloWorldViewCategory extends JViewLegacy
{
    /**
     * Display the Hello World view
     *
     * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
     *
     * @return  void
     */
    function display($tpl = null)
    {
        // Assign data to the view
        $category = $this->get('Item');

        // Check for errors.
        if (count($errors = $this->get('Errors')))
        {
            JLog::add(implode('<br />', $errors), JLog::WARNING, 'jerror');

            return false;
        }

        // Display the view
        parent::display($tpl);
    }
}

如default.php

<layout title="Category">
        <message>category</message>
</layout>
<fields
        name="request"
        addfieldpath="/administrator/components/com_helloworld/models/fields"
        >
    <fieldset name="request">
        <field
                name="id"
                type="hellocategory"
                label="COM_UNOFD_UNOFD_FIELD_GREETING_LABEL"
                description="COM_UNOFD_UNOFD_FIELD_GREETING_DESC"
                />
    </fieldset>
</fields>

没有输出, 关于创建类别文档或在线样本有什么关系吗?我尝试谷歌解决方案四天,但仍然不知道,或唯一的方法是从数据库获取数据?

1 个答案:

答案 0 :(得分:0)

闭,

因为我找到了Joomla stackExange,谢谢!

问题转移到

http://joomla.stackexchange.com/questions/17475/joomla-3-helloworld-component-category