Search

Hey guys, I’m a designer working hard to learn Symphony because it interests me. I’ve been working through Skyler’s tutorial and the Documentation pages so far and I’ve been able to do some simple things like pull from a data source.

But I’m struggling to understand the system, and I could really use another few tutorials to help me understand some of the concepts. Are you guys aware of other resources I could learn from?

As a sidenote question, I should be able to convert an old-school table layout website into a Symphony website, correct? As long as the markup is clean? Right now I’m running into an error that says “Found a top-level element table with null namespace URI”

Can you post your code on either gist.github.com or pastie.org, so we can take a look? Post both the XML and the XSLT.

Well, I think I’ve gotten past that one issue with “top level element table with null namespace URI”. I’m not worried about using tables anymore as I’ve gotten them to display.

I could still definitely use some more tutorials though. I understand the basic concepts of the system, but am having trouble writing my own XSLT and knowing where to place it.

I could still definitely use some more tutorials though.

Have you had a look at Stephen Bau’s excellent Building a Symphony Theme.

You can also watch the old screencasts at archive.overture21.com but be aware that some things are out of date as these screencasts refer to Symphony 1.7 and a lot of things changed with the release of Symphony 2.

For more advanced XSLT magic, have a look at Allen Chang’s Chaoticpattern.

I’m learning with you, and the biggest problem I had was understanding how to add more complex relationships (one-to-many, for example) between sections using data sources. I came from an MVC framework so I kept trying to compare it to models, which is half-true I guess.

In any case, Do you speak DS Editor v2? has helped me a lot so far

Man, you sound much further scott. I’ve been messing with it for two straight days now at work and have had limited accomplishments. I created a section, a data source, and got a page to display a blog sort of list of articles. I can’t figure out for the life of me how to create a new page that will show only ONE of those particular articles.

I’m usually pretty good at figuring stuff out, but I’ve never really been much of a programmer. Oh well.

I can’t figure out for the life of me how to create a new page that will show only ONE of those particular articles.

You don’t have to create a new page for this purpose - you will have to set up a URL parameter for your page. If you’re trying to create a blog, this may be your configuration:

  1. page title: Blog
  2. URL handle:: blog (generated automatically)
  3. URL parameters: title

If you save your page, you can use these parameters for templating and data source filtering. If you attach ?debug to your page (/blog/my-first-blog-entry?debug), you will find these under Params (on the right side):

  1. $page-title: Blog
  2. $current-page: blog
  3. $title: my-first-blog-entry (see the URL)

Now you need a data source to pull all your blog entries from the database. This could be your setup (assuming you’ve got a section called Entries with these fields: title, body):

  1. Name: blog entries
  2. Source: Entries
  3. Filter Entries by: select title > Add Item > Value > {$title} (this is your URL parameter)
  4. Show a maximum of: 20 results
  5. Included Elements: title, body

Attach this data source to your page Blog.

Now, if you go to /blog in your browser, the data source will return 20 entries from your Entries section, because the URL parameter $title is empty - so there no value for filtering.

I assume you’ve got a entry in your Entries section called My first blog entry which should be found under this URL: /blog/my-first-blog-entry. If you go to this URL the parameter $title will be set to my-first-blog-entry and will be used as a filter for your data source which will now only return entries that match this filter. (In this case it should be just one: your blog entry.)

Does this help?

That is supercool, thanks for the well written explanation! I got it working immediately. All I basically had to change was that url parameter on the page.

So now I’m trying to figure out how to make the “listing” appear differently than the full article. (For example, I’ve created an “excerpt” field for the blog, that displays on the listing page, but I would want the full article to appear on the actual article)

Would it be best to create a whole other page that has a different stylesheet layout? Or would it be best to use some kind of if-then testing within my original blog page to get the listing to behave differently?

Just trying to think through the strategy for using stylesheets and such.

Oh, what is this - I didn’t do anything! If there is an admin around, could you please delete these duplicated entries? Thanks!

Oh no! I deleted one of them, and it deleted all 3 or 4! Can you remember what you wrote?

Doh! I read it before it got deleted. But would appreciate the code again that you talked about. I didn’t fully understand how the test worked when you did the title !=’ ’ or something like that. Thanks again for your help, I really appreciate it.

Okay, here is my second try. We were talking about this part I think:

Would it be best to create a whole other page that has a different stylesheet layout? Or would it be best to use some kind of if-then testing within my original blog page to get the listing to behave differently?

This depends on your preferences how you like things to be organized. I normally have a master template for those elements that are repeated on every page (header, footer, etc.). Inside this template I use a choose statement to switch between “overview” and “single” mode. Something like this:

<xsl:choose>
    <xsl:when test="$title = '' ">
        <!-- markup for the overview -->
    </xsl:when>
    <xsl:otherwise>
        <!-- markup for a single article -->
    </xsl:otherwise>
</xsl:choose> 

For creating the markup inside this statement you could use something like apply-templates, call-templates or for-each depending on your task and skills. In my opinion apply-templates is one of the most powerful XSLT features but it’s hard to understand if you are a beginner - it took me quite a while to figure out how it works, but it opens up a whole new universe of possibilities. If you’re just starting to use XSLT, stay with for-each in the beginning, as it’s more straight forwards.

I didn’t fully understand how the test worked when you did the title !=’ ’ or something like that.

$title is the URL parameter which is set when you call your blog. If you’re on the overview (/blog) it’s empty, if you’re viewing a single article (/blog/my-first-blog-entry) it’s populated with my-first-blog-entry.

$title = '' checks the value of $title:
when it’s empty we’re browsing the overview,
otherwise we’re looking at a single article.

Depending on this, you should be able to create different markup for both cases.

Awesome, now I’m really starting to get the hang of this! I’m finding better success right now using for-each instead of apply-templates, so I’ll have to circle back and try to understand those further later on (since I hear they’re powerful) =)

One question about XPath that I can’t ascertain from this site. I know that I can select the first element by doing something like this:

agencynews/year/month/entry[0]

But how could I choose the 2nd through the 6th entries? Is that possible?

Try something like this:

agencynews/year/month/entry[position() &gt;= 2 and position() &lt;= 6]

Actually, I think the position() function is 1-based, so you would need to use something like this to select the first entry

agencynews/year/month/entry[1]

This is equivalent to using a predicate (the conditions within the square brackets) that looks like this:

agencynews/year/month/entry[position() = 1]

So, if you wanted to select a particular set of entries you could use an XPath expression like this:

agencynews/year/month/entry[position() &gt; 1 and position() &lt;= 6 ]

In plain language, this would read: “select every entry with a position greater than 1 and less than or equal to 6.”

Doh! Too, slow.

@TheJester12, your questions raise an issue I find in the available XSLT resources on the web. It’s difficult to search for something that doesn’t result in an ancient news group thread that looks something like this. While helpful, I feel it’s not the ideal method to find answers to questions about XSLT.

It would be good to be able to build up a library of resources for Symphony CMS, which position this site as the definitive guide to XML and XSLT.

I’m trying to get back into posting regular entries on yet another site, as I’m not ready to start importing data from my other 1.7 sites into 2.0 sites quite yet. I have ideas about doing this, but they’re not quite ready for prime time. I have a bunch of experimenting yet to do. There are so many extensions to try out, it’s a little daunting for me. If it’s daunting for me (I’ve been around since the release of 1.0), I can only imagine what it feels like for someone who is just getting acquainted with Symphony.

For anyone who’s interested, this is a live build of Symphony. It looks unfinished because it is. I’m keeping the process as wide open as possible. Every entry is available for viewing as XML and Markdown text format. The XSLT for the Journal page is available for viewing as well, including the templates for displaying the XML and Text formats. From these, you can find out what utilities I am importing to format dates and Markdown text. For that matter, you could probably guess where to find the XSL template for each of the pages of any Symphony site. The workspace tends to be wide open for anyone to see (except for PHP files, of course). It might be a good way to learn from each other (or do we want to make that information public?)

I agree bau, I have a fairly intense programming background and the biggest problem I’ve had with symphony so far is XLST. I’ve never used XLST before, and it has a fairly steep learning curve. I’ve had to play around with it based on what I think should be happening (based on old documentation), and go from there. But for someone brand new to any kind of programming, it has to be difficult to learn.

Everything else about symphony can be found (if you know what to look for) on the current forums, or the old forums, but it would be nice if there was a central location for all that stuff too. I’ve been keeping a written journal of what I’ve been doing, if I get some time I’ll try to post it somewhere.

I come from a design background, but I’ve been slowly turning into a programmer. Learning XSLT seems a little like what it used to be like to learn CSS when there were very few online resources available. There was Eric Meyer, A List Apart, Mezzoblue, Stop Design and WestCiv. I spent a lot of time on the WestCiv site at the beginning.

It seems like we need something like this for XSLT. It would significantly lower the learning curve, I think.

@scottkf, I’d be very interesting to find out what you’ve written in your journal, especially since you’re coming from a different background: intense programming.

It would be good to be able to build up a library of resources for Symphony CMS, which position this site as the definitive guide to XML and XSLT.

Stephen, I like that idea!

Besides a base of tips and tricks it would be great to have beginner tutorials. XSLT can be quite simple if you don’t let yourself be distracted by its more advanced features. If there was a place here on this website I’d like to contribute. But I see one problem: languages - for me writing in English takes some time and I’m not sure if native speakers always understand what I’m trying to say ;)

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