Search

There is a banner on a website and client would like the part of it (button below text) to act as a link. From the back-end he should be able to select any page on the website for that button's href.

I honestly have no idea how to approach that in Symphony – what would be needed is basically a list of all pages and all their sub-entities (so for example particular articles) in a dropdown or any other interface.

Example: at the website launch it will be linked to Products page (/products) but later it might have to be changed to /products/our-super-new-product or /articles/we-are-holding-an-event-next-month

Any ideas? It has to work even if someone changes handle for the page, article, product etc.

Thank you.

You could use two fields: the Page Select box, which creates a drop down of all pages, and the Select Box Link, which creates a drop down of entries.

Alternatively try the XML Select Box which lets you specify an XML feed for the drop down items. This feed could be output from a Symphony page which lists all of your pages and entries in one single list.

Hi Nick,

Thank you very much.

I have used XML Select Box as it gives a lot of flexibility. The fact that I can limit number of news displayed with DS limit to the latest few is a dream. In the end client will not link to anything older when he updates the website so no need to display all 60 articles or however many will be there in the future.

Nevertheless, here is a simple explanation of how I made it for anyone looking for similar solution.

1) Download XML Select Box extension, follow instructions for installing it. Current version is for 2.3 and doesn't work on 2.2.x so make sure you go back in GitHub's timeline to older commit if you aren't on 2.3 yet.

2) Create new page with "XML, hidden" as type and add to it default Navigation data source from Symphony as well as other data sources for entries you want to link to (for example from News section). When picking up "Included elements" for those make sure you have all you need for url handle - most typically only a title text field.

3) Format the page from the previous step with XSLT to create consistent structure for all pages; iterate through data sources you want to use and make sure they have title and handle used in the url; you can also create if statement that will not output admin, hidden, 404, 403, XML and similar pages. Content of that might look like this:

<xsl:template match="/">
    <navigation>
        <page handle=" ">
            <xsl:text> </xsl:text>
        </page>
        <xsl:apply-templates select="data/navigation/page" />
        <page handle=" ">
            <xsl:text>-----</xsl:text>
        </page>
        <xsl:apply-templates select="data/news/entry" />
    </navigation>
</xsl:template>

<xsl:template match="data/navigation/page">
    <xsl:choose>
        <xsl:when test="types/type = 'XML' or types/type = 'hidden'">
            <!-- ignore -->
        </xsl:when>
        <xsl:otherwise>
            <page handle="{@handle}">
                <xsl:value-of select="name" />
            </page>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template match="data/news/entry">
    <page handle="{title/@handle}">
        <xsl:value-of select="title" />
    </page>
</xsl:template>

4) Add XML Select Box field to section you need to link from. Follow instructions provided with the extension, they couldn't be clearer.

5) Enjoy :)

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