Joomla 3.2 add tag to component

187 views
Skip to first unread message

Takeaweb

unread,
Dec 13, 2013, 6:18:41 AM12/13/13
to joomla-de...@googlegroups.com
Hi, i'm trying to add the tags function to my custom component without success

i follow all this guides
and the one on the book
  • Learning Joomla 3 Extension development 3d edition

assuming that the name of my componentis 'mycomp'
i have the table #__mycomp_events

in the content_types table i have

    title: Mycomp

    type_alias: com_mycomp.event

    table: {"special":{"dbtable":"#__mycomp_events","key":"id","type":"Event","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}

    field_mapping: {"common":[{"core_
    content_item_id":"id","core_title":"title","core_state":"state","core_
    alias":"alias","core_created_time":"created","core_modified_
    time":"modified","core_body":"description", "core_hits":"hits","core_
    publish_up":"publish_up","core_publish_down":"publish_down","core_
    access":"access", "core_params":"params", "core_featured":"featured",
    "core_metadata":"metadata", "core_language":"language", "core_
    images":"images", "core_urls":"urls", "core_version":"version",
    "core_ordering":"ordering", "core_metakey":"metakey",
    "core_metadesc":"metadesc", "core_catid":"catid", "core_
    xreference":"xreference", "asset_id":"null"}], "special": []}


in the file com_mycomp/tables/event.php i have

    function __construct(&$db)
        {   
            $this->_observers = new JObserverUpdater($this); JObserverMapper::attachAllObservers($this);        
            parent::__construct('#__mycomp_events', 'id', $db);
        }


i also tried

    function __construct(&$db)
        {   
            parent::__construct('#__mycomp_events', 'id', $db);
            $this->_observers = new JObserverUpdater($this); JObserverMapper::attachAllObservers($this);        
        }


in the form i have

    <field name="tags" type="tag" label="JTAG" description="JTAG_DESC" class="inputbox span12 small" multiple="true" />


this field works fine, autocomplete works....

at this point, the item is saved but the tags not (not in the tags table and not in the contentitem_tag_map table)

any advice on this?


plus i have this piece of code to show the tags on the form, is right?
protected function loadFormData()

    {
        // Check the session for previously entered form data.
        $data = JFactory::getApplication()->getUserState('com_mycomp.edit.event.data', array());

        if (empty($data)){
            $data = $this->getItem();
        };

        // Load item tags
        if (!empty($data->id)){
            $data->tags = new JHelperTags;
            $data->tags->getTagIds($data->id, 'com_mycomp.event');
            $data->metadata['tags'] = $data->tags;
        }

    return $data;
    }


Reply all
Reply to author
Forward
0 new messages