Search

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

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(., "&gt;"), "&lt;")'/>
        <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.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details