Search

Hey guys.

I am using Symphony to build a website for a local company who offer a range of services...

Each service has a page which uses one .xsl file to control layout.

Pages are made in the same fashion as blog posts in the Hello World tutorials, so a new "entry" is deemed as a new "page".

The problem I am having is including these pages into a dropdown navigation dynamically.

Has anybody come across this problem before and would know the direction in which to point me? I have tried a few approaches but the navigation only shows the parent pages, including the "service-entry" page which i do not want in the navigation either...

Any help would be appreciated! :)

Hi Olly,

I would imagine the best way to approach this would be to do a for-each on the service page entries.

i.e.

<ul>
    <li>Services
        <ul>
            <xsl:for-each select="services/service/entry">
                <li><xsl:value-of select="title"/></li>            
            </xsl:for-each>        
        </ul>    
    </li>
</ul>

Does that look like it would do the job? Naturally if this is part of something more dynamic you'd want some kind of condition wrapped around the sub-menu.

If you're using the default navigation utility it has a 'hidden' page type, so you can flag pages that you don't wish to appear in your navigation (under Blueprints>Pages>[page])

Thanks for the speedy response! :)

Unfortunately the method suggested hasn't been successful. It only picks up the services page you are currently on, and will not pick anything up on other pages.

I need each entry to be made available universally across the site as it's own "page" too, which is also causing problems, as the parent page will always appear in the navigation as the ONLY page you can select...I tried including the services data source into the rest of my pages universally to create a workaround but this just crashes the site totally...

That should work assuming everything is set up correctly, however I just thought that there's the 'Parent Page' setting, I'm not sure if there's maybe a smarter way to achieve what you're after without the need for adding an extra global data source - as really this functionality should be available as part of the default navigation stuff.

Hopefully a resident expert will be along shortly to shed some light.

Hey Olly,

If I've read this right, you had the right idea adding a datasource for the entries, then you'll need to add some templating in the XSLT as Nathan indicated in his first post.

Could you elaborate on the crash you get when you add the datasource? Do you get a fatal database error or nothing at all? A copy of the error would be sweet.

And, once you can get to that stage, could you show us your XML and XSLT? Use this site and give us a link :)

Just as an aside do you have a select box link/page attachment or similar field linking each page to it's parent service entry or page?

Edited 15:49GMT as I reread the issue and made a bit more sense of it.

I created a datasource for all entries made through the parent "service-entry" page, however Im not sure the page is set to be a parent.

I set it up to run like the blog posts on the Hello world tutorial if it helps (each entry manifests itself as a page with a unique URL set up using $title as per the tutorial...but i can't get a list of all "posts - or "services" appearing in a dynamic navigation)

If i allow other pages to include the "services-entry" datasource, the pages crash and simply stop being recognised. I get a "this page does not exist". I turn off the datasource on that page and it goes back to normal..

at the moment I have stripped the XSLT back as nothing i had was working :(

Im not sure how you make an entry manifest itself as a "child" page through selects, but again any light that could be shed would certainly be of benefit!

I'll try and get a video recorded tonight or early on tomorrow if it makes things easier. I may be able to explain and shed a little more light on the problem that way! :)

Im guessing that I am relying on the data source to filter and create an individual "page view" for each associated entry, I am looking for a way to grab each entry as a page and then create a dynamic navigation which can appear on all pages...

Hey Olly

I don't think it's a noob question cause it's quite tricky:

To get a list of all posts (pages) you should create an additional datasource (pagesds) containing the page names of all entries. If you want child pages you should add a select-box link field (called parent) to your pages section directing to itself (the pages section). So you can select a parent page. add this to your datasource and you will get the following xml:

<pagesds>
    <entry>
        <name handle="page-1">Page 1</name>
    </entry>
    <entry>
        <name handle="page-2">Page 2</name>
    </entry>
    <entry>
        <name handle="page-3">Page 3</name>
        <parent>
            <item handle="page-1">Page 1</item>
        </parent>
    </entry>
    <entry>
        <name handle="page-4">Page 4</name>
    </entry>
    <entry>
        <name handle="page-5">Page 5</name>
    </entry>
</pagesds>

(page 3 has selected page 1 as it's parent, so this wil be rendered as a submenu under page 1)

Then with the following xml you should be able to create your (dropdown) menu

<xsl:template match="/">
<ul>
    <xsl:apply-templates select="data/pagesds/entry[not(parent)]"/>
</ul>
</xsl:template>

<xsl:template match="pagesds/entry">
<li>
    <a href="{$root}/{name/@handle}"><xsl:value-of select="name"/></a>
    <xsl:if test="../entry[parent/item/@id = current()/@id]">
        <ul class="submenu">
            <xsl:apply-templates select="../entry[parent/item/@id = current()/@id]" />
        </ul>
    </xsl:if>
</li>
</xsl:template>

I have made a couple of site using this method so it should work... Good luck!

Thank you for your feedback!

I managed to knock together something along the lines of what you put up, although i got a bit lost when it came to linking. I set up a checkbox link to the section name which works and the dropdown does work, however when you create an entry, you need to assign the wrong name, go back into the section and re-select the correct one to get it working....

^ got around that one by NOT making the checkbox a required field.

I need coffee....or sleep.

Cool... did you get the dropdown-menu working as well?

I had built the site to have a static main navigation but a dynamic dropdown, so the solution works fine in that respect! :) just feels a little hacky, but that's because im sure i didn't do it correctly...

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