3 users online. Create an account or sign in to join them.Users

Search

Hi Guys,

(Symphony/XSLT newbie, starting to fall in love with Symphony, XSLT not so much ;-))

I am running into some confusing issues with a Select Box Link field. First of all, I think I grasp the idea of a SBL (it’s just like a foreign key right?) but I’m having trouble actually using it in my page template.

I cannot find any examples of how to actually use the fields’ content: I need to target the linked entries in my page template but I only get a set of <item>’s with ID’s/Handles.

I feel kind of dumb not getting it, but how do I target the linked entries’ content?

Edit: My guess, at the moment, is that I need to use data source chaining, correct? (If so, how? :-P )

My setup is as follows:

  • I have a ‘Homepage’ section (a static section)
  • Homepage links to Homepage Column entries through a SBL screenshot

So, in my home.xsl page template all I’m getting back is the ‘links’ not the actual (sub-) content entries: screenshot

Another strange thing I noticed is that, on my Homepage Column overview page, the linked Homepage entry is shown 3 times: screenshot

Now, because my Homepage is a static section, I cannot access the Homepage Overview page, but I’m guessing that’s not really important a.t.m.

Can somebody point me in the right direction?

  • How do I access the SBL linked entries in my ‘parent’ page xsl?
  • Why do the ‘options’ in the Homepage SBL show just a few of the Homepage Column fields? (title, linktext, link) but not others?
  • Why does my child-entries overview show the ‘parent’ link 3 times?

Thanks!

First of all, I think I grasp the idea of a SBL (it’s just like a foreign key right?)

Right.

Another strange thing I noticed is that, on my Homepage Column overview page, the linked Homepage entry is shown 3 times

This is because you’ve selected three fields from the linked section. Just pick one. The field that you select in the list is the field that is used to build option values of the SBL dropdown form element in the “parent” entry. By virtue of selecting a single field, you link the two sections together (by ID) — the field that you select itself is for the visual connection (and shown in Data Source XML as a quick reference).

How do I access the SBL linked entries in my ‘parent’ page xsl?

Data Source chaining. In your “parent” Data Source choose your SBL field under the “Output Parameters” option. If your DS is called “Homepage” then this will create a parameter in the “pool” named $ds-homepage. If you select the SBL in the “Included Elements” list then, as you say, you’ll get just the “linked” field in the XML.

To get the full entries you need to create a second Data Source that queries from the “child” section, and filter its System ID by the $ds-homepage parameter:

`{$ds-param}`

Thanks a lot nick,

It’s obvious to me now that the selected fields from the linked section are just for display purposes (duh) thanks.

As you were writing this response I figured out to use DS chaining :-/

It might be handy to mention in the docs the fact that you need data source chaining to actually ‘retreive’ the linked entries from a SBL. I am used to Django’s ORM in which this is taken care of (more easily). I might not be the only one missing this from the start. Then again, I might be… (gets more coffee)

I am actually having linked Images in my (linked) Homepage column sections. If I need to retrieve those images in my homepage.xsl page template, do I create another chained datasource linking from Homepage or from Homepage Column? I assume I could use both?

What are the perfomance effects of all those chained datasources?

It might be handy to mention in the docs the fact that you need data source chaining to actually ‘retreive’ the linked entries from a SBL. I am used to Django’s ORM in which this is taken care of (more easily). I might not be the only one missing this from the start.

No, this is one of the most tricky concepts of Symphony to understand. Once you’d used it a few times it becomes second nature, but isn’t immediately obvious. I haven’t used Django’s ORM specifically, but I’d be interested to see if we can take any learnings from it to improve Symphony. How does it handle this scenario more gracefully?

I’m not sure about your specifics, I can’t quite figure out how your sections are set up. You might hit the limitation that a DS can output only one field as its Output Parameter?

What are the perfomance effects of all those chained datasources?

Not huge. Naturally you’re consuming more database queries, but it’s not a massive performance deficit. I presume it’s no more than an ORM building the queries to get the same data.

What are the perfomance effects of all those chained datasources?

The first datasource outputs the id’s in a comma-seperated list. Then the chained datasource uses the IN() function, which is (for as far as I know) very fast (if you have the right indexes set).

It is always better to chain then to retrieve all data and process it with xslt. The way the xml is currently beeing stored (before s3) takes up a lot of memory (way more than the database will, with the more complicated query).

Nick, Huib, thanks.

I am a frontend developer, dabbling in things like Django etc. so take my remarks concerning backend development with a grain of salt. As a frontend developer it was actually relatively easy to start with Django. (Obviously the fantastic documentation and Python language plays a role in this).

If I understand correctly Django’s ORM provides you with a Manager on query results (QuerySet). The default Manager is objects (stuffs.objects). This allows me to do for example stuffs.objects.all()' ofstuffs.objects.filter(field=”value”)` etc. These filters can be chained.

You can read more about Django’s ORM and query stuff at here.

Combined with some conventions Django also allows me to access related entries ‘backwards’ through a 'modelname_set' Manager.

Anyway, this is not meant to be a Django vs. Symphony thing. It’s just that, as a newbie, I’ve found their ORM quite easy to grasp.

Now that I know how to use DS chaining it’s not too difficult b.t.w.

One last note (ORLY :-))

As I’ve mentioned I’m having a Homepage entry that contains multiple Homepage Column entries. The Homepage Column entries contain multiple Image entries.

I have all the data, through 3 (chained) Data Sources, in my homepage XML.

Getting the Homepage Column entries was easy. Now I need to display the linked images in those columns (if any).

The only way I can get this to work is to use apply-templates in a column for-each loop. Since I need the linked image, I set a variable with the image-ID for the current column. I use this $ID variable in the predicate for my apply-templates:

<xsl:for-each select="homepagecolumns/entry">
        <xsl:variable name="imageid" select="image/item/@id" />
        <xsl:apply-templates select="/data/homepagecolumnimages/entry[@id=$imageid]" />
</xsl:for-each>

… and later on, obviously, the image template:

<xsl:template match="homepagecolumnimages/entry">
    <img src="{$workspace}{image/@path}/{image/filename}" alt="{title}" />
</xsl:template>

Is this the best way? Can I not use a ‘select-like’ value in a predicate directly? ([@id={image/item/@id}])

<xsl:apply-templates select="/data/homepagecolumnimages/entry[@id={image/item/@id}]" />

Thanks.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details