Search

So I'm about to wrap up my second project made with Symphony. I've been able to create what I wanted with it, even though I have some awkward feeling about how I made it. But it works. Embarking on yet another Symphony adventure, I need to get some things straight first.

Often I have to create structures that either involve templating a list of entries from the sections -or- singling out a certain entry and displaying it in full.

So far I've been handling it something like this. I set my Datasource to filter Title by {$entry} and then..

<xsl:template match="partners" >
<xsl:choose>
<xsl:when test="$entry=''">

// template that produces a list of entries

</xsl:when>
<xsl:otherwise> 

// template that singles out the filtered entry

</xsl:otherwise>
</xsl:choose>
</xsl:template>

I can't help but wonder if this is really the way to do it. Is there a way to choose different templates based on the presence of parameters?

There's nothing inherently wrong with how you've done it.

I typically have two different datasources, one for grabbing the data for the listing and one for displaying the individual page. This has the upside that you normally don't want all of an entries fields output in a listing, so it reduces the number of database calls.

Having an separate datasource for the detail page also lets you perform a 404 redirect if no entries are found.

In answer to your question specifically, there is also the checkbox for a datasource to only return entries if a specific parameter is set. (see screenshot).

alt text

Attachments:
Screen Shot 2012-10-09 at 2.54.48 PM.png

I think you can also do something like

<xsl:template match="partners">
    <!-- Default case -->
</xsl:template>

<xsl:template match="partners[/data/params/entry]">
    <!-- Param $entry is set -->
</xsl:template>

Thanks guys, both suggestions seem really usable.

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