Closed idgserpro closed 3 years ago
I think 2 above is the best approach.
nitf_contents.pt
can be removed, and a new class can be created for the plone.belowcontenttile.contents
viewlet:
<browser:viewlet
for="collective.nitf.content.INITF"
name="plone.belowcontenttitle.contents"
manager="plone.app.layout.viewlets.interfaces.IBelowContentBody"
class=".NITFBelowContentTitleContents"
view="plone.app.layout.globals.interfaces.IViewView"
permission="zope2.View"
/>
This new class inherit from plone.app.layout.viewlets.content import ContentRelatedItems
, overriding related_items
:
class NITFBelowContentTitleContents(ContentRelatedItems):
def related_items(self):
catalog = api.portal.get_tool('portal_catalog')
path = '/'.join(self.context.getPhysicalPath())
brains = catalog(
Type=['Link', 'File'], path=path, sort_on='getObjPositionInParent',
)
return brains
This way, we fix TODO: Fix format; see: plone/app/layout/viewlets/document_relateditems.pt
.
The disadvantage is that it may break some very specific layouts since the markup changed. But since it isn't working in the first pĺace if you have plone.app.contenttypes
installed and it's using the related items markup this shouldn't raise any concerns IMHO.
What do you think, @rodfersou and @hvelarde ? In a nutshell, we show "related items" but limited to the nitf children excluding images.
Understand, agree with the changes.
@agnogueira are we still using those layouts? Do you see any problem?
@idgserpro I don't get it: the items inside the news article are not related items.
I inferred the proposal from the comment on the original code TODO: Fix format; see: plone/app/layout/viewlets/document_relateditems.pt
. I know the items inside news article aren't "related items" the way Plone see this feature, but by doing so I could reuse the template and code from related items but now showing the children of a nitf content.
If you don't want this approach, we can try to keep what's right now on the viewlet, but we need a way to have contentFilter
feature available as well.
If I understand correctly you have a different use case that is not Plone default.
So you should add a patch or override template into brasil.gov.portal
package instead.
There's no different use case. plone.belowcontenttitle.contents
is broken in collective.nitf as shown in https://github.com/collective/collective.nitf/issues/228#issue-537754019.
What we did was show alternatives to fix the problem and based on comments around the code (like TODO: Fix format; see: plone/app/layout/viewlets/document_relateditems.pt
). The alternative is to use the code from related items: you can keep the template or copy it entirely changing the title of the pt becoming Contents
instead of Related Items
.
If you don't like the alternatives, we would like to know what you think that should be done to fix the problem.
Okay, I didn't understand right than ;-)
Really don't have a clue on how it should be fixed (sorry).
Do a collective.nitf checkout. Add plone.app.contenttypes and bootstrap the project, creating a Plone Site. Add a nitf content and an image and a pdf and a Link inside the nitf. When rendering the nitf view, you get:
Error while rendering plone.belowcontenttitle.contents
And the traceback:
In https://github.com/collective/collective.nitf/blob/729a6248ef455ec1be5d46e7ed38e5817678c63f/src/collective/nitf/browser/templates/nitf_contents.pt#L4 it seems the the snippet was based on plone/dexterity/browser/containercontentcore.pt:
But the snippet that works is from plone/app/dexterity/browser/container.pt:
But when using it,
contentFilter python:{'portal_type': ['File', 'Link']}"
doesn't work anymore and now all images of a nitf content are being shown as related when only Link and File should be.In the top of https://github.com/collective/collective.nitf/blob/729a6248ef455ec1be5d46e7ed38e5817678c63f/src/collective/nitf/browser/templates/nitf_contents.pt#L4 we have
TODO: Fix format; see: plone/app/layout/viewlets/document_relateditems.pt
. So, the question is:plone/app/dexterity/browser/container.pt
, and read the documentation/source code to see if somehow it's possible to have a similarcontentFilter
functionality?TODO
and copy what's in https://github.com/plone/plone.app.layout/blob/66defc53c59426a45adde215f8d8c17e11c592db/plone/app/layout/viewlets/document_relateditems.pt or even create a new viewlet class forplone.belowcontenttitle.contents
incollective.nitf
that inherits from it?Workaround to remove the
Error while rendering plone.belowcontenttitle.contents
: you need to remove the files or links content types created as children for the nitf content.