Search

Hello,

i’d like to create a page “service” and a section “service”. If i open http://localhost/service in the browser, the page “service” should be opened and http://localhost/service/service1 should get the content of “service1” from section “service” .

How could this be done?

I think i’ve read something like this here in the forum, but i didn’t have found it.

Lars

Hi larsk,

Do you want to list your services on the /service page? If so then one page with an url param will do it, coupled with two data sources (both pointing at your service section).

The first data source just needs as little info as you need to list the services, filter this by the page url param.

The second data source needs all the fields that you want to show on the detail view of each service. You will need to filter this too, by the url param, and also set it as a required param.

In the pages xslt, you can switch layouts based on the url param too, to display different looks for master or detail.

Hi Lars,

the following steps should help. (I’m assuming you have a input field named “Title” in your service section.)

  1. create a section-based data source with {$title} as the filter parameter for your “Title” field
  2. add a url-parameter named “title” to your “service” page
  3. attach the data source to the page
  4. edit the page template

It’s nicely documented in step 4 of the “Say Hello to Symphony” tutorial. Don’t forget the other steps/tutorials and learning from the default workspace (it’s bundled with the download package) helps a lot to grasp the concepts of Symphony.

Thank you,

i think i found a solution:

i’ve created the section “services” and a page “services”. The url-parameter for the page is “services”. I also created a datasource which has the Datasource “services” and as filter {$title} and no required url-parameter. The services.xsl contains the following code

<xsl:template match="data">
    <xsl:if test="$title = ''">
        <xsl:apply-templates select="teaser"/>
    </xsl:if> 
    <xsl:if test="$title != ''">
        <xsl:apply-templates select="services"/>
    </xsl:if>
</xsl:template>

This does work for me

You could also write it like this:

<xsl:template match="data">
    <xsl:choose>
        <xsl:when test="$title = ''">
            <xsl:apply-templates select="teaser"/>
        </xsl:when> 
        <xsl:otherwise>
            <xsl:apply-templates select="services"/>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

(slightly related, sorry if inappropriate here)

@Nils I’ve noticed the empty string in the predicate before and wonder if/why it’s necessary. The point of the test here is to check for the availability of a $title, not its value, right?

Is test="$title" not sufficient?

Hm, good question. I remember having trouble with only using $title when starting using Symphony but I have to admit that I never questioned it since then.

Can some XSLT guru explain this to me? Reading up on it it remains confusing. Apparently it has to do with result tree fragments (a concept I don’t quite get yet).

I understand that most often a <xsl:variable name="foo" select=".." /> returns a node set (/data//foo/..) but it returns a result tree fragment (/foo/my-value) when no select attribute is used and the value is based on the contents of the xsl:variable element.

Also I understand that empty nodesets return true and variables default to an empty string ""

I’ve found the following tip (using @Nils method) on SO, but still I would think I can check for the existence of a variable (disregarding its value) without testing for an empty string… halp?

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