2013-08-19, 23:08:39
The Categories were designed to help you better classify of Items and to organize them logically by their Fields. Categories more relevant for the Item Manager internal processes and have no business on frontend anyway.
Please note: do not use Categories to store information like URLs or Titles, better use the custom fields instead.
For example in your case, you can customize your categories by creating additional custom fields like: "group_url" and "group_title". It also maybe makes sense to specify the default value for these fields since the members of category have the same contents.
The value of the group_url contains an URL of your hyperlink which indicates the link’s destination.
The group_title field contains the title you want displayed for your category.
So, your category links shall be structured as follows : <a href="[[ group_url ]]">[[ group_title ]]</a>
And the component might then look like this:
Please note: do not use Categories to store information like URLs or Titles, better use the custom fields instead.
For example in your case, you can customize your categories by creating additional custom fields like: "group_url" and "group_title". It also maybe makes sense to specify the default value for these fields since the members of category have the same contents.
The value of the group_url contains an URL of your hyperlink which indicates the link’s destination.
The group_title field contains the title you want displayed for your category.
So, your category links shall be structured as follows : <a href="[[ group_url ]]">[[ group_title ]]</a>
And the component might then look like this:
PHP Code:
<?php
$manager = new ImController();
$preferences = imModel::getPref();
// Register your link template
$manager->tplRegister(array(
'loop' => '<a title="Click to go to category..."
href="[[ my_group_url ]]">[[ my_group_title ]]</a><br />'
));
foreach($preferences->categories->category as $cat)
{
// setup items by category
ImCategory::setCategory($cat);
$manager->runModelMethod('gen_register', array('group_url', 'group_title'));
$items = $manager->getModelValue('items_ordered_struct');
// Render your link template
echo $manager->paint('loop', array(
'my_group_url' => $items[0]['group_url'],
'my_group_title' => $items[0]['group_title']
));
}
?>