RyanMcClelland
6 years agoExpert
Customize Post a Question Button
We would like to either suppress the Post a Question button or redirect it to the Case Portal page (/t5/crmsupport/page) if a user has a certain role.
Khoros previously developed a custom component for the post button. The code is pasted below. I'm wondering if more could be added to the text below to change the behavior of the button for two new roles.
<#include "theme-lib.common-functions.ftl" />
<#assign postUrl = "" />
<#switch page.name>
<#case "CategoryPage">
<#assign postUrl = webuisupport.urls.page.name.PostPage.path("category-id",coreNode.id).path("choose-node","true") />
<#break>
<#case "ForumPage">
<#case "ForumTopicPage">
<#assign postUrl = webuisupport.urls.page.name.PostPage.path("board-id",coreNode.id) />
<#break />
<#default>
<#assign postUrl = webuisupport.urls.page.name.PostPage.path("choose-node","true") />
<#break />
</#switch>
<#if postUrl?? && postUrl?has_content>
<#attempt>
<#assign rolesQuery = "select * from roles where users.id = '${user.id?c}'"/>
<#assign rolesList = executeLiQLQuery(rolesQuery, false, true) />
<#list rolesList as role>
<#if role.name?lower_case == "direct">
<#assign postUrl = postUrl.path("product-id","Direct")/>
<#elseif role.name?lower_case == "office">
<#assign postUrl = postUrl.path("product-id","Office")/>
</#if>
</#list>
<#recover>
</#attempt>
</#if>
<#assign postUrl = postUrl.build() />
<#if postUrl != "">
<div class="post-btn-wrapper lia-button-wrapper">
<a href="${postUrl}" class="post-btn lia-button lia-button-primary">${text.format("menubar.button.new_message")}</a>
</div>
</#if>
RyanMcClelland - You can wrap this line of code in attempt recover as shown below:
<#attempt>
<#assign postUrl = postUrl.build() />
<#recover>
</#attempt>
Let me know if this helps.
Thanks!