Inline images
This is an open discussion with 4 replies, filed under General.
Search
For custom inserts I use the ninja technique. The client only have to do in the editor:
[insert>something-cool<]
<xsl:template match="*" mode="html"> <xsl:element name="{name()}"> <xsl:apply-templates select="* | @* | text()" mode="html" /> </xsl:element> </xsl:template> <xsl:template match="@*" mode="html"> <xsl:attribute name="{name()}"> <xsl:value-of select="." /> </xsl:attribute> </xsl:template> <xsl:template match="p[starts-with(text(), '[insert')]" mode="html" priority="1"> <xsl:param name="position"/> <xsl:variable name="insert" select= 'substring-before(substring-after(., ">"), "<")'/> <xsl:choose> <xsl:when test="$insert='something-cool'"> DO A TEMPLATE HERE </xsl:when> </xsl:choose> </xsl:template>
interesting, how's the xslt performance when you have a lot of paragraphs on a page? I guess still not too bad. I've never used text matching, more node matching, so I'd have something like and then convert with ninja technique. I usually have a UI take care of the insert, but I use a fairly complicated setup with the images uploaded through an Association Field.
The performance is normal or not not notable bad as far as I have seen.
But it is an amazing trick that gives the user flexibility and the feeling that they are coding :-)
In case it's useful there's some more discussion on this here, though it's about the ninja technique like plenaforma already covered above.
Create an account or sign in to comment.
Hello,
I need to set up a fool-proof section where the client uploads pictures, and then inserts them in the text flow. The easiest, the better. MD is ok.
All suggestions are welcome!
Thanks