Search

There are a number of threads that talk about this issue, but none that seem to resolve my specific issue sufficiently (or at least unambiguously).

I have a blog with a publish date field and a tag list with categories in it. I want my URI to be /blog/category/date/ where category can be one of the tags in the tag list, it can also be “all” or “” (nothing).

Currently in the filter for category I have {$category} (where category is the param passed on the page obviously). Is it possible to attach some kind of conditional statement on that that would allow me to use “all” as a wildcard statement of some kind. My first attempt was to do something like {$category!all} but of course that didn’t work. I also tried the field: filter extension but then realised that this is not what it’s used for.

So in short, I want to apply a wildcard to the filter that allows either a single recognised or all unrecognised values to be used to not filter the result set.

P.S. I’ve only been using Symphony for the last day and I love it.

I want my URI to be /blog/category/date/ where category can be one of the tags in the tag list, it can also be “all” or “” (nothing).

If it’s nothing then you’d have the URL /blog/2010-01-01 therefore your $date becomes your $category. When a parameter is used in a filter has no value, that filter is ignored. So by not passing a category you essentially remove the category filter.

If you want to show all articles for a particular date then you could always have two pages:

/blog/by-category/{$category}
/blog/by-date/{$date}

RESTful URLs can get a bit messy when you need parameters higher up the URL to become optional. Alternatively therefore you could use GET parameters to get around the “optional-ness” of your requirement:

/blog/?category=X&date=Y

(Which creates params named $url-category and $url-date to filter on.)

The last resort would be to customise the code of the Data Source itself if you’re comfortable meddling in PHP. Inside the grab() function of the DS you can check the $this->_env array, find the url part, and if category equals all then unset() your category filter ($this->dsFILTERS[...]). If you do, be sure to remove the allowEditorToParse function which will prevent you opening the DS in the Symphony DS Editor and overwriting your changes.

Have you tried {$category:all}?

But when $category doesn’t exist that will surely look for entries which have been assigned a category named “all”?

Oh right, it’s more about the URL and less about the DS… You could try to use + in your URL: /blog/+/2009-09-12/.

Nick’s solution of url-params is the better option here. I’ve had the same outcome when trying something similar.

Thanks Nick,

What I was trying to do was have all of the following situations work:

/blog/

This would yield all of the latest blog entries, ignoring both category and date.

/blog/branding/

This would yield all of the latest branding options, regardless of date.

/blog/branding/2010-01/

This would yield all of the branding articles from Jan, 2010.

/blog/all/2010-01/

This would yield all articles from Jan, 2010, ignoring category.

GETs look like the way to go for the moment, thanks. If I wanted to either hack the functionality or start to look toward writing an extension to provide it, could anyone point me to the place to start looking?

Thanks

The last paragraph of my post above should be enough for you to customise your Data Source. It will simply remote the category filter when the URL Parameter category has a value “all”.

Ah cool, thanks.

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