help to better help you:

Please: add always Joomla / JEM version and details to your posts, so we can try to reproduce your issue!

[info] Adding Tag option (J3+)

[info] Adding Tag option (J3+)

10 years 11 months ago
#11998
With Joomla 3 it's possible to define an option for Tags and maybe it's nice to use in the future.

There is a tutorial explaining how to use it but it can be a bit difficult to make it work so here goes the info.



Create entry in Database
- find table content_types and add the corresponding info
- copy/alter the info of article/category


BACKEND

Add code in table class

For example:
Code:
function __construct(&$db) { parent::__construct('#__jem_events', 'id', $db); JTableObserverTags::createObserver($this, array('typeAlias' => 'com_jem.event')); }
This is different then in the tutorial but it works.


Add field to the form
Code:
<field name="tags" type="tag" label="JTAG" description="JTAG_DESC" class="inputbox span12 small" multiple="true" > </field>


Add code to the model

function getitem()
Code:
if (!empty($item->id)){ $item->tags = new JHelperTags; $item->tags->getTagIds($item->id, 'com_jem.event'); }


function save()
Code:
if ((!empty($data['tags']) && $data['tags'][0] != '')) { $table->newTags = $data['tags']; }



FRONT

Add code to the model
function getItem()
Code:
// Get the tags $item->tags = new JHelperTags; $item->tags->getItemTags('com_jem.event', $item->id);


Add code to the view
Code:
<?php $row->tagLayout = new JLayoutFile('joomla.content.tags');?> <?php echo $row->tagLayout->render($row->tags->itemTags); ?>

Attachments:

Please Log in or Create an account to join the conversation.

Time to create page: 0.482 seconds