1

Plone's viewlets appear to be site-wide by default. How can I make a viewlet only appear on a certain page?

Giacomo Spettoli
  • 4,476
  • 1
  • 16
  • 24
joeforker
  • 40,459
  • 37
  • 151
  • 246

2 Answers2

2

This is done with Theme Interface in Plone. Check this documentation:

http://plone.org/documentation/manual/theme-reference/buildingblocks/components/themespecific

If u created your Theme / viewlet with a paster template, all should be in place and ready to use.

  • The link above seems not reachable. You might want to see http://docs.plone.org/develop/plone/views/viewlets.html#conditionally-rendering-viewlets for reference. – marr Oct 07 '15 at 08:08
2

In addition to theme-specific viewlets, mentioned by @user276028, you can create browserlayers for non-theme viewlets:

Example taken from collective.atimage.transformtoolbar:

  1. Create a browserlayer (you can create them with paster localcommand addcontent browserlayer):

  2. Use the layer in viewlet registration:

    • Edit your viewlet registration in configure.zcml with a layer attribute pointing to your interface.

In the configure.zcml linked file you can also see how to show the viewlet just for some content types (for property) and just for default view of that content type (view property).

Any other case, I think you should decide when to show/hide your viewlet code or template, like in the available method.

marcosfromero
  • 2,853
  • 17
  • 17