Category / Tag GUI -- Assigning to content
I've enabled the generic tags and categories modules per
http://docs.getfuelcms.com/general/tags-categoriesI've also created a number of tags and categories successfully via the Fuel interface.
My question however is this:
How do I assign these tags and/or categories to pages?
/fuel/pages/edit/[id #] doesn't seem to have a way to add them to the content.
Do I have to custom code in that ability?
Comments
My_fuel_layouts.php
$tagOptions = $this->fuel->tags->options_list();
and added to 'fields' this: 'tags' => array('type' => 'multi', 'sorting' => TRUE, 'mode' => 'checkbox', 'label' => 'Tags', 'options' => $tagOptions),
It would be nice to pull all categories, and then look up what tags belong to each and print them off. And a final pull for tags that didn't belong to a category.
If you associate a category to a tag in the CMS, you will be able to access all the tags associated to that category:
$categories = fuel_model('categories'); foreach($categories as $cat) { foreach($cat->tags as $tag) { echo $tag->name; } }
That will allow sorting / pages with particular tagged/categorized content
Outputs
[Parent Cat. Name] -> [Category Name] -> [Tag Name]
And uses the $tag->slug for the layout variable value
$tagOptions = array(); $categories = fuel_model('categories'); foreach($categories as $cat) { if($cat->parent_id != 0){ $parent = $categories[$cat->parent_id -1]->name." -> "; } foreach($cat->tags as $tag) { $tagOptions[$tag->slug] = $parent.$cat->name.' -> '.$tag->name; } }