I have a Force.com site portal written completely with custom Visualforce, HTML and CSS.

I have a component which is used to display the navigation links at the top of the page. This navigation is built using and

  • tags which is pretty common.

    <ul id="hdrnav">
                    <li><a href="/apex/billing" id="billnav">Billing</a></li>
                    <li><a href="/apex/deposits" id="depositsnav">Deposits</a></li>  
                    <li><a href="/apex/checks" id="checksnav">Checks</a></li>   

    Now I want to be able to render these

  • links based on the user's security as each of these links display information from different custom objects.

    I know we can check a user's access to a record using something like:


    So how can I achieve something like not displaying the

  • link for deposits if the user has no access to the deposit custom object.

  • 3
    • Are you on Force.com Sites or Site.com?
      – joshbirk
      Nov 6, 2012 at 17:09
    • Force.com sites. Editing.
      – Richard N
      Nov 6, 2012 at 17:15
    • Just bind in output pannel .Should be good what Josh suggesting Nov 6, 2012 at 18:02

    4 Answers 4


    Off the cuff, I believe you can overload the use of the <apex:variable> tag along with its rendered attribute to show/hide individual elements.

    <apex:variable var="foo" rendered="{!$ObjectType.objectname.accessible} >
        <li> bar ... </li>
    • This worked for me, however I had to add the value='foo' attribute. Sep 3, 2013 at 21:19

    This is a bit off the cuff, but I think you can wrap it in a panel:

    <apex:outputPanel rendered="{!$ObjectType.objectname.accessible}" layout="none"><!-- content --> </apex:outputPanel>

    Would that work in your case?


    One option would be to compose them server side, then display with <apex:dataList> or <apex:repeat>. Useful especially if the list will grow in future?

    To do that build some wrapper apex class (or even something as simple as Map<String, String>) that would hold the URL and display name. Anything you can do in VF with {!$ObjectType.Account.accessible} you can check with Account.sObjectType.getDescribe().isAccessible()

    • 2
      This answer gets my vote as it keeps the business logic in the controller where it belongs, while the page simply iterates the collection it is given and renders it. Nov 6, 2012 at 17:46
    • @BobBuzzard Thx :) I'm torn about that one to be honest. Sometimes I do a lot of magic in rendered if it's just for display related, not manipulating the data. Plus I think describes used on the page don't count towards the governor limit?
      – eyescream
      Nov 6, 2012 at 17:51
    • Thanks for letting me how I can do this in the controller as well. The answers here will help folks no doubt. For my specific purposes and for its simplicity to implement, I will go with Kevin's solution. Another thing is I know VF will render <Apex:DataList> as <ul> and <li>. I wish Salesforce gives us new apex equivalents of <ul> and <li>. I have some formatting CSS on these elements as well. Thank you. Upvoting.
      – Richard N
      Nov 7, 2012 at 16:37

    If the VF level or Controller level is not an option (the two first things I would try) - then you could also potentially control it via jQuery. Give the LI's you want to hide a specific class, and then tie it back to a function which checks if the user has the permission, and then shows the LI (instead of the other way around).


    You must log in to answer this question.

    Not the answer you're looking for? Browse other questions tagged .