collective / collective.portlet.contentleadimage

0 stars 3 forks source link

Using the original collection.pt template instead of its own #2

Open jmce opened 12 years ago

jmce commented 12 years ago

I installed collective.portlet.contentleadimage in a Plone 4.1.6 instance, and it seemed ok until I created such a portlet. I then noticed that such portlets end up using the regular collection portlet template instead of the template in the package.

portal_view_customizations shows 2 "collection.pt" items under "zope.interface.interface". The link for one of them has href="@@customizezpt.html?required=zope.interface.Interface,zope.publisher.interfaces.browser.IDefaultBrowserLayer,zope.browser.interfaces.IBrowserView,plone.portlets.interfaces.IPortletManager,collective.portlet.contentleadimage.contentleadimagecollectionportlet.IContentLeadImageCollectionPortlet&view_name=collection.pt" but one ends up viewing the same template instead of the one included in the source of collective.portlet.contentleadimage ...

shagi commented 12 years ago

I can't reproduce this. I have installed collective.portlets.contenleadimage in a fresh Plone 4.1.6 and everything seem ok.

Maybe you have overwritten the collection.pt? If so, try overwriting also the template for ContentLeadImagePortlet, using the original contentleadimagecollectionportlet.pt.

Can you try running the tests?

jmce commented 12 years ago

Thanks! I did forget to mention that I had previously customized (via portal_view_customizations) the basic collection portlet template (before installing collective.portlet.contentleadimage). Removing that customized template, afterwards, didn't solve the problem. On the other hand, still with my original customized template in there, trying to also customize the 'other' collection.pt from portal_view_customizations [apparently associated wih your product but actually showing the same default template text] failed with

BadRequest: The id "zope.interface.interface-collection.pt" is invalid - it is already in use.

Perhaps I'll try: -- reinstalling with no customized collection.pt present -- or (corresponding to what you suggest above) customizing first the template from your product, renaming the customized version in the ZMI to match the corresponding original file name, and then customize the default collection.pt; -- or (harder for lack of time) trying installing in a fresh Plone instance with none of the other currently installed add-ons

I haven't enough knowledge of Plone's entrails to be aware if any of the above should make any difference, or if any 'registration' bit is missing in your product and leading to this collision. Anyway, I'll report here anything I notice...

shagi commented 12 years ago

From the three possible solutions you provide, don't try the last, I have done it and it works :-).

Customizing the template before or after customizing collection portlet should make no difference.

This configuration should work fine:

  <!-- overwrite collection portlet template -->
  <plone:portletRenderer
      portlet="plone.portlet.collection.collection.ICollectionPortlet"
      template="collection.pt"
      layer=".interfaces.IThemeSpecific"
      />
  <plone:portletRenderer
      portlet="collective.portlet.contentleadimage.contentleadimagecollectionportlet.IContentLeadImageCo
      template="contentleadimagecollectionportlet.pt"
      layer=".interfaces.IThemeSpecific"
      />

I don't know if there is a way to especify the original contentleadimagecollectionportlet.pt file, but just copying to your theme should work.

Good luck!

jmce commented 12 years ago

Deinstalling and later reinstalling with the original collection.pt (the one from plone.portlet.collection) no longer customized, portlets in your product did get rendered with contentleadimagecollectionportlet.pt — but this stopped happening again as soon as I customized that collection.pt via portal_view_customizations (actually even with no changes in the customized version). I have a feeling this could also happen in your fresh installation. I still haven't tried also customizing the 'other' collection.pt (setting it to a copy of contentleadimagecollectionportlet.pt) or testng the portletRender config you suggest above, but given the lack of time I'll probably proceed with that later option.

jmce commented 12 years ago

Btw, I met another problem while one of portlets I tested with was already using contentleadimagecollectionportlet.pt: http://pastie.org/4800103 --- a UnicodeDecodeError processing tag() for a link with some non-ASCII characters in its title, it seems. Apparently not relevant for collective.portlet.contentleadimage (maybe just a redturtle.smartlink bug) even though I hadn't met it in other contexts with the same objects. Lacking time for much testing [probably will even avoid redturtle,smartlink for now] but if I find some relevant compatibility issue I'll submit it here.

jmce commented 12 years ago

Ooops, tried adding those plone:portletRenderer in your configure.zcml [maybe I misunderstood, or maybe I forgot/still haven't seen how to handle this properly] and Plone entered a startup loop [reaching "ZServer HTTP server started" but then back to beginning]

I then Ran sudo -u plone bin/plonectl debug and got this traceback: http://pastie.org/4829306

Probably something simple that I should be aware of but, given some urgency here, today I'll probably just customize the default collection portlet template for my current needs instead of using collective.portlet.contentleadimage, but hopefully next week I may return to this w/ more testing... Thanks again, sorry for not being able to proceed for now.

shagi commented 12 years ago

Could you post the zcml used for customization? I think the portletrenderer inteface could be wrong.

About redturtle.smartlink, after customizing contentleadimageportlet, try replacing

            <img src="" alt=""
                 tal:condition="python: not item_has_leadimage and item_has_image"
                 tal:replace="structure python:item_object.tag(scale=view.data.scale, css_class='portletItemDetails')" />

with

            <img src="" alt=""
                 tal:condition="python: not item_has_leadimage and item_has_image"
                 tal:replace="structure python:item_object.tag(scale=view.data.scale, css_class=u'portletItemDetails')" />

(just make css_class parametter unicode)

I think it is the only place where contentleadimage could be broken, I'm not familiar with smartlink.

jmce commented 12 years ago

Right now collective.portlet.contentleadimage is not installed in the instance where I met those problems, but hopefully I'll try it again (and reply to the zcml q above) in another instance in few days...

As for the UnicodeDecodeError, I met it too just using collective.contentleadimage, for objects with non-ASCII characters in title: https://github.com/collective/collective.contentleadimage/issues/6 For now I had to patch the tag method of ImageField in Archetypes, in order to prevent it (forcing str decoding with utf-8 instead of ascii), even if not sure if that will be the proper 'official' solution.

jmce commented 12 years ago

Btw, in case it may help: a similar bug, using the original collection.pt tempoate instead of its own, is happening now with redturtle.portlet.collection, in the same Plone instance (again with collection.pt customized in portal_view_customizations). https://github.com/RedTurtle/redturtle.portlet.collection/issues/1

Perhaps some common cause? I'll let you know if I find some workaround..