Search

I've been trying to wrap my head around best practices for building blogs in Symphony, and there are two features are default in most blogs that I'm not sure about in Symphony.

  1. Dated URLs (eg articles/year/month/day/title). The way that I've been thinking about doing is to use a single page and XSL stylesheet and url parameters. However, this ends up with a really huge xsl stylesheet and a lot of datasources which is pretty resource intensive.
  2. Next/previous post links: This one has me miffed, I've noticed that none of the blog ensembles do this either.
  3. Duplicate titles: This one is alleviated with dated URLs and good content strategy, but is there some magical way to automatically make unique URLs from duplicate entry titles? (I suppose I could tack on the entry's system ID, but maybe someone else has a better idea.)

My initial thought with the dated URLs is to use data sources for years, months, and days for the landing pages and a fourth for the article. But that means that any single page query wastes time making 3 unnecessary data source queries. Is there a more efficient way to do this?

Next/previous post links: This one has me miffed, I've noticed that none of the blog ensembles do this either.

Here is one way to do it.

Hey I've just built a blog with the date url schema you're talking about.

All I did was to have an Articles page and with a Articles data source attached.

In your Page editor enter the following in the URL Paramerters box year/month/day/title

Those are the four parameters you will use to filter to your data source.

Now in the your Articles data source editor you simply need to filter by two different fields:

1) In the 'filter by' bit of the data source editor use the drop down to select 'Date' and click 'Add item'. Then in the value box simply enter {$year}-{$month}-{$day} (this is referencing the url params you entered in your page).

2) Now use the drop down to select 'Title' - add it and then in the value box enter {$title}

Now if you go to your Articles page and enter a url that matches an entry

eg if you created one yesterday you might have http://yoursite.com/articles/2011/04/29/handle-of-your-article

you'll see in your XML that only the entry that matches that will appear.

This means your XSL template can be extremely simple as you don't need to do any filtering. You can simply output your article using stuff like <xsl:value-of select="/data/articles/entry/title"/> because there will only ever be one match.

If you're worried about forcing unique handles you might use the Unique Text Input Field extension although I'm not sure if it's compatible with the latest version of Symphony. I wouldn't think you'd have much of an issue though if you're using the date schema above.

As to the Previous And Next question - have a read of this thread to see if it helps

If you don't want to edit your data sources in the past I've created a very basic datasource (not paginated) which only has the the Article titles and dates in it. This is attached to the Articles page and used has a reference for going forward and back.

ie You can get the entry id of the current article, select that in the list of all articles and then find the entry that comes after it and link to it. Also helpful because you can check to see if you are at the end of the list or the start and show the appropriate buttons.

Hopefully that was some help.

Thanks! My search-fu somehow failed me with the next/previous datasource. I will be trying

For the dated URLs, do you have landing pages for year/, year/month, and year/month/day as well?

The Unique Text Field extension creates a unique handle for entries if it detects a conflict. It would result in urls like /hello-world, /hello-world-2, /hello-world-3, etc.

I haven't noticed any issues with it in Symphony 2.2.1

@thebestsophist - I don't tend to have landing pages for year/, year/month, and year/month/day (although the filtering will work perfectly for that) on/using the same page as my individual article view. The reason I don't is for error handling. If none of your params are "required" (in that you can just have year, or year/month or whatever) then if someone enters or visits an incorrect {$title} you will have no easy way to show and error because your filter will still return a list of results that match the date entered. If you make {$title} required you can redirect to a 404 when there is no matching result.

I generally prefer to have a separate archive page on which to use that kind of filtering - in which case you just use the same filtering set up but sans the title param.

Duplicate titles

The Text Box Field also forces unique titles IIRC.

Dated URLs

I don't usually bother with these, but if you want to achieve this structure cleanly then I'd use the URL Router extension and create them as separate Symphony Pages. This way you can have clean URLs and pass only the parameters you care about (and the datasources you need for each use-case). Plus that way there's no "controller" logic in your templates.

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