2

What is the simplest way to do this? I added it in the portlets.xml file in profiles/default. It is now available in the "Add portlet" dropdown when I go to @@manage-portlets. But I need it automatically created.

Is it possible to explicitly specify the set of portlets I want on the right and left columns inside my profiles/default?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
sureshvv
  • 4,234
  • 1
  • 26
  • 32

3 Answers3

4

The portlets.xml file does a few different things and there's a difference between registering a kind of portlet that can be added and actually adding a portlet, both of which can be done in portlets.xml. You need to use an "assignment" element to add a portlet:

<assignment
   manager="plone.rightcolumn"
   category="context"
   key="/plone"
   type="plone.portlet.static.Static"
   name="foo-portlet">
  <property name="header">Foo Portlet Title</property>
  <property name="text">Foo portlet contents...</property>
</assignment>
Ross Patterson
  • 5,702
  • 20
  • 38
3

You can register your classic portlet trough the portlets.Classic portlet, configured with a template and macro name, using an assignment element in your portlets.xml file:

<assignment
    manager="plone.rightcolumn"
    category="context"
    key="/"
    type="portlets.Classic"
    name="my-classic-portlet"
    visible="1">
  <property name="template">templatename</property>
  <property name="macro">macroname-found-in-template</property>
</assignment>

See the Portlets section of the GenericSetup manual on Plone.org or the original PLIP for details on Portlet assignments and GenericSetup.

The properties match the portlet dataprovider interface, see the Classic Portlet source code for the interface definition for the Classic Portlet.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
2

For a not experienced product developer (even the others too) the easiest way to achieve this kind of automation is:

  1. do manual configuration o assignment like a any other common plone user/administrator, going in the portal's root and adding the portlets you want.
  2. go in zmi -> portal_setup -> export tab
  3. select portlet step and export it
  4. use portlets.xml in the tar.gz just got.

this xml contains all what you need: registrations and assignments... actually, even a little more stuff so may be a good thing to make a clean of what unneeded in it.

sauzher
  • 378
  • 4
  • 12
  • Yes. I made exactly this recommendation the last time I saw a GenericSetup question. – Auspex Apr 13 '11 at 20:57
  • Funny, for me it's often step 3.5: find the relevant data is not exported. (Possibly not in this case, though.) – Ulrich Schwarz Apr 14 '11 at 12:51
  • it also generates loads of stuff depending on how people have been playing with their dashboard. Can be a pain to filter out the junk. – sureshvv Apr 15 '11 at 17:00
  • Yes, indeed! I said "the easiest" not "the better" ;) – sauzher Apr 18 '11 at 08:00
  • Plus it doesn't seem to work. For eg. I don't want the login portlet. Export seems to give me the correct file. But when I install my product, the login portlet still remains. How do I get it explicitly removed? – sureshvv May 05 '11 at 07:00
  • Generic setup has an additive logic. This is the cause you still see login portlet. I don't know what write in xml to remove something. I these cases i write my own setuphandler step to grab portlet assignments in a specific context and fix the situation. Here you can find a hint: http://pastie.org/1867241 HTH – sauzher May 05 '11 at 08:55