0

ステップ15の「ACLの追加」まで、joomlaの「MVCコンポーネントの開発」ドキュメントをたどった後

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

すべてが機能し、

しかし、フロントエンド カテゴリ ビューの作成について何も表示されなかったので、新しいビュー「カテゴリ」を追加します。コードは次のとおりです。

管理フィールドフォルダーで、hellocategory.php を作成します。ほとんどのコードは helloword と同じですが、変更するだけです

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();

view.html.php

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.xml

<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>

default.php

<?php var_dump($category); ?>

何も出力されません。オンラインでカテゴリ ドキュメントまたはサンプルの作成について何かありますか?4 日間 Google で解決策を試しましたが、まだわかりませんか、それともデータベースからデータを取得するしか方法がありませんか?

4

1 に答える 1

0

閉まっている、

JoomlaのstackExangeを見つけたので、ありがとう!

質問はに移動します

http://joomla.stackexchange.com/questions/17475/joomla-3-helloworld-component-category
于 2016-08-11T17:58:42.343 に答える