WebCenter Tips and Tricks, Part 3

January 13th, 2012 Leave a Comment

Editor’s note: Here’s the third installment of WebCenter tips and tricks from Matthias Müller-Prove (@mprove). Check out the first two here.

Tips’n’Tricks for WebCenter #3: How to display custom page titles in Spaces
by Matthias Müller-Prove

If people don’t know where they are in the web, they tend to get lost in cyberspace. This can be prevented by displaying the page title for your pages in Oracle #WebCenter Portal Spaces. (At least they won’t get lost in your WebCenter space.) All you have to do is to create a custom page template and use it as default in your space. Its head section will contain a few code snippets to display the title. Add an HTML box and enter e.g.<h1>#pageDocBean.title</h1>: 

That’s it. That is the basic idea.

Caveat: This does not work for wiki pages and HTML pages because they do not have a specific title in WebCenter. #pageDocBean.title will just return ‘Wiki’ or ‘Resource’.

Now let’s get a little bit more sophisticated. A space has a title as well. So let’s use it:

<h1>#spaceContext.currentSpace.metadata.displayName &ndash; #pageDocBean.title</h1>

Are you ready for level 3? Now I want to add more styling, and I want to have a special treatment for the home page to display the tagline for the space. Here is a preview of the final result, first the home page, then any other page in the space:

To accomplish this behavior, I have to use a conditional statement #{ BOOL ? CASE1 : CASE2 }. WebCenter’s expressions cannot be nested, hence the conditions will be tested several times to get the desired result:

<h1 style="margin-top: 0px; margin-bottom: 0px;">
<span style="color: #9a9a9a; font-size: 80%;">
#{pageDocBean.title != 'Home' ? spaceContext.currentSpace.metadata.displayName : ''}
</span>
<span style="color: #9a9a9a;">
#{pageDocBean.title == 'Home' ? spaceContext.currentSpace.metadata.displayName : ''}
</span>

<br />

#{pageDocBean.title != ‘Home’ ? pageDocBean.title : ”}
<span style=”font-size: 80%;”>
#{pageDocBean.title == ‘Home’ ? ‘Information Matters’ : ”}
</span>
</h1>

Yes, you are correct. Thanks for paying attention. The image of the lady is missing in my code example.


Possibly Related Posts

Leave a Reply