Using the new Tags API on an input field

225 views
Skip to first unread message

Joe Palmer

unread,
May 7, 2013, 8:09:50 AM5/7/13
to joomla-de...@googlegroups.com
Hello,

I would to implement the new tags interface on a 3rd party input field (using Joomla 3.1.1). I am using a template override so I can customise the output and have added this code:

        $chosenAjaxSettings = new JRegistry(
            array(
                    'selector'    => '#custom_tags',
                    'type'        => 'GET',
                    'url'         => JURI::root() . 'index.php?option=com_tags&task=tags.searchAjax',
                    'dataType'    => 'json',
                    'jsonTermKey' => 'like'
            )
        );
        JHtml::_('formbehavior.ajaxchosen', $chosenAjaxSettings);

This seems add the relevent JavaScript code to the head and the input field has an id of custom_tags but I get the following JS error:

Timestamp: 07/05/2013 13:06:18
Error: TypeError: Joomla.JText._ is not a function
Source File: /media/jui/js/ajax-chosen.min.js
Line: 5

Ideally the field would simply save the tags as a comma seperated string within the 3rd party component but I am also happy to save the tags in the internal database instead if that is easier.

Is this possible to do with the new tags API? Any help or pointer would be great appreciated.

Many thanks,

Joe

Ove

unread,
May 7, 2013, 8:16:34 AM5/7/13
to joomla-de...@googlegroups.com, Joe Palmer
Hi Joe,
It's not your component? Then you have to fork it and make some more
changes.

You can find Elin's description on how to implemen tags for a component here
http://docs.joomla.org/Using_Tags_in_an_Extension

Ove
> --
> You received this message because you are subscribed to the Google
> Groups "Joomla! General Development" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to joomla-dev-gene...@googlegroups.com.
> To post to this group, send an email to
> joomla-de...@googlegroups.com.
> Visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Ove

unread,
May 7, 2013, 8:19:48 AM5/7/13
to joomla-de...@googlegroups.com, Joe Palmer
Or better! Ask the extension developer to add Tags to his component.

elin

unread,
May 8, 2013, 6:19:57 PM5/8/13
to joomla-de...@googlegroups.com, Joe Palmer
I second asking them to do it first, less likely to be a problem in the long run. Just like I think modifying core files is not a good idea, modifying extension files is also a problem if you ever want to upgrade or want support etc. If the developer really is not willing then you could probably use something like Julio's code override plugin to modify the code and a form plugin to add a tags field to the editor. 

We tried to make it relatively easy to opt in if you you are using the Joomla MVC and we've gotten some code since then that will make it even easier for 3.1.2.  

Elin

AJH

unread,
May 11, 2013, 1:40:54 PM5/11/13
to joomla-de...@googlegroups.com, Joe Palmer
Hi Elin,

Thanks for writing up the article.  Question :

In the section "Add or modify a delete() method", why not just use the JHelperTags member that was instantiated in the implemented JTable class?


elin

unread,
May 18, 2013, 12:52:47 PM5/18/13
to joomla-de...@googlegroups.com, Joe Palmer
Hmm good point. Maybe some uncleaned up example code .. this is how we finalized in contact

public function delete($pk = null)
{
$result = parent::delete($pk);
return $result && $this->tagsHelper->deleteTagData($this, $pk);
}


Elin
Reply all
Reply to author
Forward
0 new messages