WebCenter Tips and Tricks, Part 3

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>

  • First I apply an inline style for h1 to remove some space above and below the heading.
  • Then I ask for the page title, and if it is not ‘Home’ (every page but the home page) then I display the space name at size 80% and gray.
  • Just for the home page I display the space name in size 100%.
  • New line for the page title.
  • Now the same distinction fot the page name. For every page but the home page I display the page title.
  • If this code is executed on the home page then I display ‘Information Matters’ – the tag line for the space – instead of the page title.

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

AboutJake

a.k.a.:jkuramot

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.