Closed neilferreira closed 8 years ago
You are correct in that a such helper is currently missing and is the only way to figure out the tiles in use. Contribution for that would be welcome :)
I think the reason for a such obvious missing feature is historical. There used to be "tile book keeping", but it was eventually removed as unnecessary and error-prone. Also the original xhtml-based tile syntax used to require a dedicated link tag for each tile in the page layout html, which made cheap to read the current tiles from layout. But now that both of those are gone, the only way is to look for data-tiles.
Neil Ferreira notifications@github.com kirjoitti 12.2.2016 kello 11.05:
I'm looking to create a "table of contents" style navigation for all of the tiles on a page that has a "title" parameter
The only way to find all of the tiles on the page seems to be to use xpath to generate these, getting the configuration would be a task of its own then.
Does anyone have any convenient way to achieve this? I'm using Plone5 and plone.app.mosaic.
— Reply to this email directly or view it on GitHub.
Do you have any pointers handy on how to iterate through the tiles? Or would it be purely browsing the source of plone.app.blocks and looking at how the transform is being done?
At first, you should get the layout for the current content. The easiest way is to render plone.app.blocks.layoutbehavior.ContentLayoutView
. That's because the layout may be either in the content field or from a shared storage.
Then you should parse the resulting HTML with lxml.etree.fromstring and iterate through all the data-tile-attributes. There's XPath expression for that in plone.app.blocks.utils.bodyTileXPath
. You could look through the utils-module about how that's used.
Once you have the URLs from data-tile-attributes, you can get the tile view classes (with their data as its data-property/attribute) with restrictedTraverse.
I found an alternative solution, using diazo to achieve this. Closing
I'm looking to create a "table of contents" style navigation for all of the tiles on a page that has a "title" parameter
The only way to find all of the tiles on the page seems to be to use xpath to generate these, getting the configuration would be a task of its own then.
Does anyone have any convenient way to achieve this? I'm using Plone5 and plone.app.mosaic.