Search

Hi,

I’m new to Symphony and very impressed with it so far. The Tutorials and Concepts have been useful but I’ve run into an issue with my site structure that I could use some extra help with. It’s a common scenario so I imagine there will be an easy answer but unfortunately the explanation will be a bit long.

Here’s what I want to achieve. Given a particular Section, say Articles, I would like to have an archive of all entries at:

www.example.com/articles

with the individual articles available at URLs like:

www.example.com/articles/title-of-my-article

I was able to set up the Data Source, Page and Page Template for the archive page pretty easily but ran into trouble with the individual entries. Here’s what I did.

  1. Created a second Data Source with a URL Parameter of $title to pull back the article with the Title specified in the URL.

  2. Created a new Page with a URL Parameter of title that used the new Data Source.

But I couldn’t work out how to get the correct URLs for the individual entries. Making the new Page a child of the archive Page gave URLs like this:

www.example.com/articles/url-handle/title-of-my-article

And if I made the page a child of root I couldn’t reuse the ‘articles’ URL handle. So here’s what I did next.

  1. Added the URL Parameter title to the archive Page.

  2. Added the second Data Source to the archive Page (so that it uses both Data Sources).

  3. Added a test of the $title parameter to my Page Template to work out which type of page is being displayed (archive or individual entry) and apply the appropriate template.

From a front-end perspective this works perfectly but when I check the debug I can see that I’m getting archive and individual entry data returned all the time (which makes sense as I’m using both Data Sources).

This isn’t a huge issue for the archive page because no individual entry results are returned (as $title is unset). But for individual entries I get the full archive returned as well which isn’t exactly efficient.

So what’s the proper way to do this? I would prefer to keep the archive and individual entries in a single Page Template but can switch to two if necessary.

Apologies for the lengthy post and many thanks in advance. Paul

Hi Paul!

Have you taken a look at the default Symphony workspace? It splits the articles and the archive into two pages, but provides a nice example.

Alternatively, you can filter the articles datasource by your article title handle (which should be an url paramater). This way, when no article title is given all articles are returned, and when an article title is set only this article is returned.

Or, if you have good reasons why you want to use 2 data sources (e.g. more details for individual entries) you can have a look at the filter field extension.

Good luck, and feel free to post any more questions!

Hi Carsten,

Thanks for the swift response. I kept the two Data Sources (as they return different data) and filtered the archive Data Source as you suggested.

This means that on an archive page ($title unset) I get all data from the archive DS and none from the individual entry DS. And on individual entry pages ($title set) I get the relevant record returned by the individual entry DS and by the archive DS.

So for individual pages I still get an extra archive record returned but this is much better than having all of them returned. It’s not perfect but it’ll do for now while I am still playing with the system.

I have a few other questions but will try to pace them out a bit to avoid spamming the board.

Cheers. Paul

I managed to refine this a bit thanks to this thread. I changed the filter on the archive DS to filter on System Id instead of Title. System Id never matches the $title parameter so requesting an individual article no longer outputs archive results.

This is now working pretty well but it’s a bit messy on the Data Source side. I have this nagging feeling that I’m going about things the wrong way and that continuing along this path will lead to problems later. As well as the archive/entry URL structure I also want to support articles by author and keyword using either:

www.example.com/articles/authors/author-name

www.example.com/articles/keywords/keyword-name

or:

www.example.com/articles?author=author-name

www.example.com/articles?keyword=keyword-name

And there are two other Sections that need similar functionality. I’m wary of ending up with Data Source spaghetti so if anyone has any best practice advice for this kid of setup, please let me know. I reckon the solution will include:

  1. Separate Data Sources for archives and individual entries (unless there is a way to dynamically choose Data Source elements based on parameters?)

  2. A single Page with both Data Sources (this is the only way I was able to get the URL structure I wanted although it’s very convenient to have the archive and entry XSLT in the same template)

I’d love to hear any suggestions. In the meantime I’ll be trawling the forums.

Cheers. Paul

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