在扩展中使用标记帮助Joomla

时间:2018-05-08 10:33:46

标签: joomla tags custom-component

我想在自定义组件joomla 中设置标记字段,但我不能这样做!

我已遵循本指南https://docs.joomla.org/J3.x:Using_Tags_in_an_Extension#Creating_the_record但仍然无法做到,有人可以尝试对此进行更多解释。

感谢您的所有传入帮助(我绝望:)) 我尝试但是我有很多错误,我是joomla的新手,我只想在我的自定义组件中使用标记字段。

修改

所以我从这里开始是因为我不了解其余的https://docs.joomla.org/J3.x:Using_Tags_in_an_Extension#Modify_your_component.27s_table_class_.28or_classes_if_you_have_multiple_tables.29

我补充说:

$this->_observers = new JObserverUpdater($this); JObserverMapper::attachAllObservers($this);

对我来说: admin / tables / projectinfo.php (我不知道他是否应该这样做)http://prntscr.com/jf84sb

代码:http://prntscr.com/jf8ac2

然后:https://docs.joomla.org/J3.x:Using_Tags_in_an_Extension#Add_tags_to_the_getItem.28.29_method_of_the_model我没有那个,因为是为了joomla 3.1.4。 ????

https://docs.joomla.org/J3.x:Using_Tags_in_an_Extension#Add_a_tag_field_to_edit_screens我认为这是好的:D

https://docs.joomla.org/J3.x:Using_Tags_in_an_Extension#Prepare_the_view我没有站在一个东西,我只是按Ctrl-P到:

管理员\视图\ projectinfo \ view.html.php

并把它放在这里:

/**
 * @package     Joomla.Administrator
 * @subpackage  com_projectinfo
 *
 * @copyright   Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

/**
 * ProjectInfo View
 *
 * @since  0.0.1
 */
class ProjectInfoViewProjectInfo extends JViewLegacy
{
    /**
     * View form
     *
     * @var         form
     */
    protected $form = null;

    /**
     * Display the PROJECTINFO view
     *
     * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
     *
     * @return  void
     */
    public function display($tpl = null)
    {
    /*THIS LINE*/ $item->tags = new JHelperTags;
    $item->tags->getItemTags('com_projectinfo.projectinfo' , $this->item->id);/*THIS LINE*/
        JHtml::_('jquery.framework');
        $document = JFactory::getDocument();
        $document->addScript(JURI::root() . "/administrator/components/com_projectinfo"
                                          . "/models/fields/js/catch.js");
        // Get the Data
        $this->form = $this->get('Form');
        $this->item = $this->get('Item');
        $this->script = $this->get('Script');
        // Check for errors.
        if (count($errors = $this->get('Errors')))
        {
            JError::raiseError(500, implode('<br />', $errors));

            return false;
        }


        // Set the toolbar
        $this->addToolBar();

        // Display the template
        parent::display($tpl);

        // Set the document
        $this->setDocument();

        $this->item->tagLayout = new JLayoutFile('joomla.content.tags');
        echo $this->item->tagLayout->render($this->item->tags->itemTags);

    }

    /**
     * Add the page title and toolbar.
     *
     * @return  void
     *
     * @since   1.6
     */
    protected function addToolBar()
    {
        $input = JFactory::getApplication()->input;

        // Hide Joomla Administrator Main menu
        $input->set('hidemainmenu', true);

        $isNew = ($this->item->id == 0);

        if ($isNew)
        {
            $title = JText::_('COM_PROJECTINFO_MANAGER_PROJECTINFO_NEW');
        }
        else
        {
            $title = JText::_('COM_PROJECTINFO_MANAGER_PROJECTINFO_EDIT');
        }

        JToolBarHelper::title($title, 'projectinfo');
        JToolBarHelper::save('projectinfo.save');
        JToolBarHelper::cancel(
            'projectinfo.cancel',
            $isNew ? 'JTOOLBAR_CANCEL' : 'JTOOLBAR_CLOSE'
        );
    }
    /**
     * Method to set up the document properties
     *
     * @return void
     */
    protected function setDocument() 
    {
        $isNew = ($this->item->id < 1);
        $document = JFactory::getDocument();
        $document->setTitle($isNew ? JText::_('COM_PROJECTINFO_PROJECTINFO_CREATING') :
                JText::_('COM_PROJECTINFO_PROJECTINFO_EDITING'));
        $document->addScript(JURI::root() . $this->script);
        JText::script('COM_PROJECTINFO_PROJECTINFO_ERROR_UNACCEPTABLE');
    }

}

在此之后,我很困惑,我退出了很多错误,最后一个就是这个:

警告:在第35行的C:\ xampp \ htdocs \ Joomla_3.8.7-Stable-Full_Package \ administrator \ components \ com_projectinfo \ views \ projectinfo \ view.html.php中从空值创建默认对象

注意:未定义的属性:第36行的C:\ xampp \ htdocs \ Joomla_3.8.7-Stable-Full_Package \ administrator \ components \ com_projectinfo \ views \ projectinfo \ view.html.php中的ProjectInfoViewProjectInfo :: $ item

注意:尝试在第36行的C:\ xampp \ htdocs \ Joomla_3.8.7-Stable-Full_Package \ administrator \ components \ com_projectinfo \ views \ projectinfo \ view.html.php中获取非对象的属性“id”

TY

0 个答案:

没有答案