How to display a panel only on a particular page?

Last modified by Vincent Massol on 2016/07/05

As a user wanting to display a panel (e.g. with some links) only on a particular page (e.g. on "Main.WebHome") you can do the following:

1. Create or edit the panel

Make sure that the panel's code resembles the following:

#if ($doc.fullName == "Main.WebHome")
  * [[News>>Blog.News]]
  ** [[Iasi>>Blog.Iasi]]
 #if ($xwiki.hasAdminRights())
  [[$services.localization.render('xe.panels.edit')>>path:${xwiki.getURL('Panels.newtwo', 'inline')}]]

The pages Blog.News and Blog.Iasi (from this example) should already exist, otherwise the links will point to non-existing pages.

The key to deciding if a panel should be displayed or not on a page is the following condition in the code which (in this case) decides that the panel should only be displayer on the homepage:

#if ($doc.fullName == "Main.WebHome")
... panel content here ...

The final panel creation should resemble the following:


2. Register the panel

Add the panel to the desired column (e.g. to the right column) from Administration > Page Elements > Panels displayed on right column:


3. Navigate to Main.WebHome to see the panel displayed only on the homepage


In the our example, we have used Main.WebHome as the page where to display the panel but you can use any other page or pages from your wiki and you can make the rule as complex as you want.

Get Connected