Restrict number of topics & page list
Permalink
Good day,
Is it possible to restrict how many topics a user can select for a page? I'm working on a project where ideally the user would only be able to select one topic per page.
My second questions relates to this. In a page list, I want to set additional CSS classes on HTML elements (the grid-items) depending on the selected topic. I've modified the thumbnail_grid template as below, but I'm not sure whether this is the best way to achieve this.
What do you think?
Cheers,
B.
Is it possible to restrict how many topics a user can select for a page? I'm working on a project where ideally the user would only be able to select one topic per page.
My second questions relates to this. In a page list, I want to set additional CSS classes on HTML elements (the grid-items) depending on the selected topic. I've modified the thumbnail_grid template as below, but I'm not sure whether this is the best way to achieve this.
<?php foreach ($pages as $page): $topics = $page->getAttribute('category_topic'); $topicClass; if ($topics) { foreach ($topics as $topic) { // get the tree node ID $treeNodeID = $topic->getTreeNodeID(); // get the tree node name $treeNodeName = $topic->getTreeNodeDisplayName(); switch ($treeNodeName) { case 'Seminars': $topicClass='topic-seminars'; break; case 'Events': $topicClass='topic-events';
Viewing 15 lines of 28 lines. View entire code block.
What do you think?
Cheers,
B.