Oracle VM Site Review - Oracle VM Health Check
view counter

Tips'n'Tricks for WebCenter #3: How to display custom page titles in Spaces

Thanks to Matthias Müller-Prove for this story

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.

Oracle Virtualization and Cloud Consulting
view counter

#pageDocBean.title

:

edit page template

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:


#spaceContext.currentSpace.metadata.displayName – #pageDocBean.title

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:

Space's header for home page

Space's header for every other page

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:



#{pageDocBean.title != 'Home' ? spaceContext.currentSpace.metadata.displayName : ''}


#{pageDocBean.title == 'Home' ? spaceContext.currentSpace.metadata.displayName : ''}

#{pageDocBean.title != 'Home' ? pageDocBean.title : ''}

#{pageDocBean.title == 'Home' ? 'Information Matters' : ''}

  • 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.

Read the entire article at its source

view counter