3

I am working on a full customer portal but have run into a slight issue. I have to put a title on every page that is dynamic and can easily be changed by someone who does not code. I would like to simply display whatever is in the description box for that page. Using Force Explorer I was able to create a query using the Visualforce Page label,

SELECT Description, Name FROM ApexPage Limit 10

I pulled the name also so I could verify the pages easily. The problem is I am not able to add this to my VF pages. Currently I have,

<head>
  <title>{!$ApexPage.Description}</title>
</head>

But I get an error message saying that the field does not exist. Does anyone know how to render this field without using any type of controller?

2 Answers 2

4

Great idea, love the reuse! I've tried $Page.pageName.Description and $CurrentPage.Description both result in failures to save the page, so it seems we are out of options in respect to reusing the Description. However we are not yet out of code free options, given your original requirement....

  • Custom Setting. Create a Hierarchy Custom setting (under Setup > Develop) and add fields for each page (it would help to name them consistently with the page name). Then in each of your pages you can reference these without code via {!$Setup.PageDescriptions__c.page1__c}. This also btw has the nice side effect of allowing you to customise the description based on the user or profile!
  • Custom Labels. Under the Create menu you will find Custom Labels, these can also be referenced without code in your Visualforce pages, and can also be translated into multiple languages (something the above and ApexPage Description routes cannot do). You can create Custom Labels based again on the name of your pages and also categorise them in order to create a List View to access them easily amongst others. The syntax would be {!$Label.page1} for example.

Given the two options, the Custom Label route gets my vote because it feels more aligned with your needs, though the ability to customise by user or profile might be appealing, that said, there is no reason why you cannot combine both...

Hope this helps!

2
  • Thank you sir!! This is a great idea and works with what we desired.
    – Grady D
    Commented Apr 14, 2014 at 15:29
  • 1
    Label gets my vote as well because it can be translated if desired. Nice answer, Andy! Commented Apr 14, 2014 at 22:09
5

My most likely Visualforce global candidate would be $CurrentPage but this page:

<apex:page>
    {! $CurrentPage.Name }
    {! $CurrentPage.URL }
    {! $CurrentPage.Description }
</apex:page>

produces a:

Field Description does not exist.

error at compile time. So I think you are probably out of luck (without a controller).

1
  • This is what I was worried about :/ thanks for trying!
    – Grady D
    Commented Apr 14, 2014 at 15:29

You must log in to answer this question.

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