Forum Discussion

skylinegtr's avatar
10 years ago

Adding logo using API

Hello!

I would like to add a logo next to the title of any section that is internal only (via API?) Is this possible?

 

 

We are currently using API calls for our dropdown menu 

 

The dropdown menu code looks like this:
 <#assign categories = rest("/categories").categories />
           <#list categories.category as category>
           <li><a href="${category.@view_href}">${category.title}</a>
               <ul class="menu menu-flash-array">
                    <#list rest(category.@href+"/boards").boards.board as board >
                    <li><a href="${board.@view_href}">${board.title}</a></li>
                    </#list>
                </ul>
            </li>
            </#list>
 
Thank you!
 
  • skylinegtr - You could may be do something like this, I haven't run the code, so please look out for any issues.

     

    <#if user.registered >
    	<#assign is_user_admin = false />
    	<#assign is_user_mod = false />
    	<#assign is_user_emp = false />
    		<#list restadmin("/users/id/${user.id?c}/roles").roles.role as role>
    			<#if role.name?? && (role.name == "Administrator")>
    				<#assign is_user_admin = true />
    				<#break />
    			<#elseif role.name?? && (role.name == "Moderator")>
    				<#assign is_user_mod = true />
    				<#break />
    			<#elseif role.name?? && (role.name == "Employee")>
    				<#assign is_user_emp = true />
    				<#break />
    			</#if>
    		</#list>
    	<#if is_user_admin >
    		This is for Admin
    	<#elseif is_user_mod >
    		This is for Mod
    	<#elseif is_user_emp >
    		This is for Emp
    	</#if>
    </#if>

7 Replies

  • skylinegtr's avatar
    skylinegtr
    Mentor
    10 years ago

    VarunGrazitti- Thanks! Display components based on role would be my second option. I would really like to add the logo next to the title. 

     

  • skylinegtr's avatar
    skylinegtr
    Mentor
    10 years ago

    VarunGrazitti-Thanks for the link. I've deciding to add a component instead. The only thing I don't know how to do is have an API call query the page you're currently on, then display which roles can read that page. I've tried the example code but it's not working for me. 

  • skylinegtr's avatar
    skylinegtr
    Mentor
    10 years ago

    VarunGrazitti- I got it to work. However, I have to create multiple components and use if/else statement.

     

    <#if user.registered >
    <#assign is_user_admin = false />
    <#list restadmin("/users/id/${user.id?c}/roles").roles.role as role>
    <#if role.name?? && (role.name == "Administrator")>
    <#assign is_user_admin = true />
    <#break />
    </#if>
    </#list>

    <#if is_user_admin >
    <@component id="Internal-Only" />
    </#if>
    </#if>

     

    If I create just one component like this:

     

    Instead of creating 2-3 components and applied different images to each components( Example)

     

    All Members: (component1 display Image#1, Image#2, Image #3) after sgined in

    Employees: (component2 display Image#1, Image#3) after sgined in

    Partners: component#3 display Image#1, Image#4) after sgined in

     

    Is there a way for me to create only one component and have an API call to display those image by role? If an employee signed in, it will only display  Image#1, Image#3 using API. 

     

    Thanks!

  • VarunGrazitti's avatar
    VarunGrazitti
    Boss
    10 years ago

    skylinegtr - You could may be do something like this, I haven't run the code, so please look out for any issues.

     

    <#if user.registered >
    	<#assign is_user_admin = false />
    	<#assign is_user_mod = false />
    	<#assign is_user_emp = false />
    		<#list restadmin("/users/id/${user.id?c}/roles").roles.role as role>
    			<#if role.name?? && (role.name == "Administrator")>
    				<#assign is_user_admin = true />
    				<#break />
    			<#elseif role.name?? && (role.name == "Moderator")>
    				<#assign is_user_mod = true />
    				<#break />
    			<#elseif role.name?? && (role.name == "Employee")>
    				<#assign is_user_emp = true />
    				<#break />
    			</#if>
    		</#list>
    	<#if is_user_admin >
    		This is for Admin
    	<#elseif is_user_mod >
    		This is for Mod
    	<#elseif is_user_emp >
    		This is for Emp
    	</#if>
    </#if>
  • skylinegtr's avatar
    skylinegtr
    Mentor
    10 years ago

    VarunGrazitti-Great! Thanks for all the help! It works.

     

    Is it possible to have the image display to a role and a specific page (current node)?

     

     

    I've figured it out. Just need to add the following code.

     

    <#if coreNode.id == "Page_Name">
    </#if>