Since version 4.6.0, Tags (topics) and Hashtags can be used at the same time. So, we prepare this tutorial to help you can integrate your app with both of them.
h2. TagsNote: we will use the app To Do List as an example for this tutorial.
Scope
: only in the app.Related Setting
: Enable Tags (tag.enable_tag_support) - Enable this option if you wish to allow tags on the site to create topics for the item being added.Tags
for your item in add/edit form{if Phpfox::isModule('tag') && Phpfox::getParam('tag.enable_tag_support')} {module name='tag.add' sType='todo'} {/if} |
In controller of edit page, we need to get get tags list of editing item
if (Phpfox::isModule('tag') && Phpfox::getParam('tag.enable_tag_support')) { $todo['tag_list'] = Phpfox::getService('tag')->getForEdit('todo', $id); } |
// Add this php code in service add if (Phpfox::isModule('tag') && Phpfox::getParam('tag.enable_tag_support')) { if (isset($aVals['tag_list']) && ((is_array($aVals['tag_list']) && count($aVals['tag_list'])) || (!empty($aVals['tag_list'])))) { Phpfox::getService('tag.process')->add('todo', $iItemId, Phpfox::getUserId(), $aVals['tag_list']); } } |
// Add this php code in service update if (Phpfox::isModule('tag') && Phpfox::getParam('tag.enable_tag_support')) { if (Phpfox::isModule('tag') && isset($aVals['tag_list']) && !empty($aVals['tag_list'])) { Phpfox::getService('tag.process')->update('todo', $aVals['task_id'], $aVals['user_id'], $aVals['tag_list']); } } |
// Add this php code in controller of detail page to get tags list if (Phpfox::isModule('tag') && Phpfox::getParam('tag.enable_tag_support')) { $aTags = Phpfox::getService('tag')->getTagsById('todo', $id); if (isset($aTags[$id])) { $aItem['tag_list'] = $aTags[$id]; } } |
<!-- Add this code in view template --> {if isset($aItem.tag_list)} {module name='tag.item' sType='todo' sTags=$aItem.tag_list iItemId=$aItem.task_id iUserId=$aItem.user_id sMicroKeywords='keywords'} {/if} |
getTagLink
. This callback will return link to search item by tag of the app. Example:/** * @return string */ public function getTagLink() { return Phpfox_Url::instance()->makeUrl('to-do-list.tag'); } |
Scope
: using for entire site. You can support to add hashtags in description of your items.Related Setting
: Enable Hashtags (tag.enable_hashtag_support) - Enable this option if you wish to allow hashtags on the site to create topics for the item being added.// Add this php code in service add if (Phpfox::isModule('tag') && Phpfox::getParam('tag.enable_hashtag_support')) { Phpfox::getService('tag.process')->add('todo', $iItemId, Phpfox::getUserId(), $aVals['description'], true); } |
// Add this php code in service update if (Phpfox::isModule('tag') && Phpfox::getParam('tag.enable_hashtag_support')) { Phpfox::getService('tag.process')->update('todo', $aVals['task_id'], $aTodo['user_id'], $aVals['description'], true); } |
parse
:{$aItem.description|parse} |