Ticket #12503 (confirmed Feature Request)
diazo should have move command
Reported by: | djay | Owned by: | ldr |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | Diazo (plone.app.theming) | Version: | 4.1 |
Keywords: | Cc: | frisi, loechel |
Description
Somethings there is a need to move content around and at the moment you have to resort to complicated xsl.
For example currently to move a viewlet in diazo you would do
<!-- Move social like viewlet to the bottom --> <xsl:template css:match="#viewlet-below-content">
<xsl:copy>
<xsl:copy-of select="@*"/> <xsl:copy-of select="//*[@id='viewlet-social-like']"/> <xsl:apply-templates/>
</xsl:copy>
</xsl:template> <drop css:content="#viewlet-social-like"/>
Whereas this could be simplified to
<!-- Move social like viewlet to the bottom --> <prepend css:content="#viewlet-social-like" css:content-target="#viewlet-below-content" /> <drop css:content="#viewlet-social-like"/>
Change History
comment:3 in reply to: ↑ 1 ; follow-up: ↓ 4 Changed 4 years ago by djay
Replying to ldr:
Its cool that those methods exist. They are nice than what I had and it would be good to document them as I don't remember seeing them on diazo.org.
However I'd arguing its still too complicated to understand. I'm not sure what method=raw means. I think to understand most of those methods you need to know how the xslt is work underneath. I'd argue that resorting to xslt is a power user feature. Moving content around just in the content document, before it's places into the theme is a very common use case and it would be nice to support that in a more direct easy to understand way. maybe a <move> pimiative, or a using a <append content-target=... It could be just me, but these things seems to a more natural fit to the existing non xslt primitives.
comment:4 in reply to: ↑ 3 Changed 4 years ago by ldr
Replying to djay:
Its cool that those methods exist. They are nice than what I had and it would be good to document them as I don't remember seeing them on diazo.org.
They're documented at http://docs.diazo.org/en/latest/advanced.html#modifying-the-content-on-the-fly - it's fairly new, I think I wrote them on the plane to the last Plone conf.
However I'd arguing its still too complicated to understand. I'm not sure what method=raw means. I think to understand most of those methods you need to know how the xslt is work underneath. I'd argue that resorting to xslt is a power user feature. Moving content around just in the content document, before it's places into the theme is a very common use case and it would be nice to support that in a more direct easy to understand way. maybe a <move> pimiative, or a using a <append content-target=... It could be just me, but these things seems to a more natural fit to the existing non xslt primitives.
I agree that method="raw" is a bit of a hack, hopefully including the top element unconditionally will mean most people never have to use it. It's documented at http://docs.diazo.org/en/latest/basic.html#replace and there's an example in Martin's book (which is much more narrative than diazo.org.) The method attribute defines the way in which that rule's content is fetched,
The underlying difficulty with implementing before/after/append/prepend on content is that XSL is a transform language rather than an in-place modification language, so there's not much to build on there. I think I can solve it for a Diazo 1.1 or 2, but coming up with a good syntax is tricky given everything in Diazo is about copying stuff from the content into the theme, it might have to end up being:
<after css:content-children="#foo"><include css:content="#bar/></after>
But maybe the real solution is to just make it easier to modify the template that generates the original content, which is Deco's mission really.
I'm hoping the combination of not dropping the first included element and an <include> directive will tide things over for a Dexterity 1.0 release and mean almost nobody need resort to xsl.
BTW. The rules append and prepend have been deprecated, we now have their synonyms <before theme-children=...> and <after theme-children=....>.
comment:7 Changed 4 years ago by loechel
The method="raw" is a cool feature that might help sometimes, but there are use-cases where a real move is necessary:
<!-- Manipulate the Portal Breadcrumbs --> <drop css:content="#breadcrumbs-you-are-here" /> <replace css:content-children=".breadcrumbSeparator" >></replace> <!-- move it to new place --> <replace css:theme-children="div#above-master-main" css:content="#portal-breadcrumbs" method="raw" /> <!-- remove it from original context --> <drop css:content="#portal-breadcrumbs" />
The Problem is that the manipulation rules will be ignored, as the moving must use method="raw" or the breadcrumb bar will show up twice.
Please add a way to really move an element away. maybe by a method="move".
By the way, what is confusing, in Deliverance from which Diazo is originally inherited the rules move the elements from their original context away. I'm sure that this has something todo with the re-implementation of XDV/Diazo on XSLT base.
comment:9 in reply to: ↑ 8 Changed 4 years ago by ldr
Replying to loechel:
Ensuring that a replace overrides a drop for the element it selects (but not that element's descendants) would solve this. Definitely one for Diazo 1.1.
While Diazo is a direct descendant of Deliverance 0.2, Deliverance 0.3 (which made everything a move) is more of an cousin :)
Diazo currently supports method=raw for replace/before/after on the theme so that no modification happens to the included content, so this works:
For modifying the content itself you can simplify your xsl to:
Though I think you mean:
It would be good to have a nicer spelling of that <xsl:apply-templates> and that's probably easier than trying to implement before/after with <replace content=... />, though that should be possible too.
Also, we really want to have before/after/replace ignore any drop or content modification of the top element that's included, that would mean method="raw" would not often be needed.