Search

I'd like a page to show a specific piece of content from a section if no parameter is present, and the content specified by the parameter otherwise. Both would show content from the same section.

For example, if you visit /architects, you would see the first architect. If you visited /architects/john-smith, you would see John Smith.

One way to do this would be to create two data sources. The first datasource would pull just the content. The second would pull the content based on the parameter. In the template, I would do an xsl:if test for the parameter and display one or the other as appropriate.

Is there a way to do this by specifying a default value for a parameter? That seems like it would be cleaner / more maintainable, but I didn't see the option anywhere.

Yes, the docs say you can use

{$architect:hans-dampf}

The value would be hans-dampf until you overload it by setting the appropriate param using the URL.

However, what you're describing sounds more like

  • Order by Date or ID, descending
  • Set Limit to 1, page 1
  • Use {$architect} as parameter

That way you would get the latest architect, sorted by Date or ID by default. But if you provide the parameter, the architect would be fetched by name.

Ah, got it, thanks! The ID solution will would be safe (safer) vs. client changes as well.

I had googled around for default value / default parameter, but wasn't getting results.

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