6 users online. Create an account or sign in to join them.Users

Search

Guys,

Currently working to create a new 'website' which I hope to re-package as an ensamble once done that features pages and 3 tier navigation.

Say I have a section called Static Pages that allows static pages to have a parent 'page'. So it would be something like /about/staff/web/ in a previous website I've seen with a similar 3 tier navigation; an extension was used which attaches itself to FrontendOutputPreGenerate grabs a copy of the XML then uses FrontendOutputPostGenerate and replaces all links by doing basically a find-replace function; and using the Datasource XML to extract the page hierarchy.

PS for link creation all the links were output from the XSL in the form of href='#page:123' where 123 is the entry id of the static page.

Whilst the above system works I believe it is highly inefficient in fact my bottleneck on this website is XSLT generation. The reason the above was used I assume are the following.

  1. The pages are multilingual and not all handles are known when generating/translating pages.
  2. Its easier for translators to just use a page-id rather then look for the actual link when translating content that contains links.
  3. No actual need to go through all the data if sometime it is decided to change the page handle of a particular page.

Whilst I can possibly generate basic links using XSLT I am not sure I can apply something of a replace within say a body tag.

I assume something related to a ninja technique to do a match on all links of the sort <a page='123'>My Anchor</a> and replace with the proper output via an xsl computation would be possible?

small update maybe some XSLT of the sort

<xsl:template match="body//*">
<xsl:choose>
    <xsl:when test="name(.) = 'a' and  @link!=''">
        <a><!-- Create the href in here -->
        <xsl:apply-templates/></a>
    </xsl:when>
    <xsl:otherwise>
        <xsl:element name="{name()}">
            <xsl:apply-templates select="@*"/>
            <xsl:apply-templates/>
        </xsl:element>
    </xsl:otherwise>
</xsl:choose>

Would you think this is efficient?

<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:choose>
        <xsl:when test="name(.) = 'page'">
            <xsl:attribute name="href">
                <xsl:call-template name='page-link'><xsl:with-param name='id' select='current()'/></xsl:call-template>
            </xsl:attribute>
        </xsl:when>
        <xsl:otherwise>
            <xsl:attribute name="{name()}">
                <xsl:value-of select="."/>
            </xsl:attribute>
        </xsl:otherwise>
    </xsl:choose>

Basically I managed to resolve the issue - for anyone who ever needs a clue the above code should work - not 100% sure about efficiency due to recursion but should not be a major problem since it is only 4 levels deep and will only happen if there are links of that structure. This can be replicated with different sections instead of using page one can use whatever they want.

The template page-link should be a recursive template that creates the required link structure.Blockquote

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details