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

Search

A client has requested that they be able to choose from a set of templates to display the content from a single section. I had to find a solution to allow a template name to be selectable in the CMS.

We agreed that we would build templates for them, and input the name into a section, which could be SBL linked to the content.

Then comes the fun bit...

In xsl, a template can have a name and a match, which makes it possible to choose a template dynamically based on the content of an xml node.

I've added it to a Gist here for you lot to see.

Because of the way the templates are being called, the xml data must be passed through as a parameter, this is the only drawback here.

Because of the way the templates are being called, the xml data must be passed through as a parameter, this is the only drawback here.

There's a cleaner way to do it. Have a look at the comment I wrote to your gist.

@designermonkey, @vladG thanks so much for this templating tips. Also other guys for all other great tips.

One question: Can you get inside those templates any key() values? E.g.

<xsl:value-of select="key('text', 'heading')"/> ...

I use some xsl keys throughout my xsl files and they do not return any values when used inside those templates. I don't see any point there. But variables do function.

@designermonkey that's a neat one used it plenty of times before :) only issue is that when you're in the 'inner' templates you don't have access to the root node. what I tend to do is pass $data to represent /data

@juro this I assume relates to what I've just explained. You lose your context as you are now matching the <xsl:template> node. rather then your XSLT so you would need a variable to access back your data.

@gunglien thanks for explanation. I had keys for a data tag with its own context setup. Cool, now I understand it a bit better.

Yep. I have that too locally, just not updated the gist.

Here are a couple sites that have good XSL tips and tricks.

What's happened with Utilities folder? Have some tips to use Master.xsl etc.. in new version?

All XSL editors have been removed since Symphony version 2.4 as the vast majority of developers would prefer to use a code editor on their local machine (with the many benefits that come with that) than to edit XSL templates via the admin interface.

If you'd like to restore this functionality then you need Workspace Manager B.

Not really a tip but more a method, I am working on a website for a client who needs to be able to easily modify large sets of informations. First I have to say I am not a real developer (more a graphic designer), I have decided to use an Excel xml 2004 format as the basis of the backend, for ease of use for the client.

Every row of the Excel file generates a basic page of the site (contact infos of a person or group of persons). For now this is about 250 people so the excel file is not a huge thing to parse with symphony and it probably won't exceed 1000 rows. So to achieve various groups of the rows (needed on the pages depending on her level) I have a single xml page parsing the Excel file with 3 parameters : request | filter type | filter value. Depending on those parameters the xml output is used as a remote datasource (with filter value as a parameter), for the infos needed on the upper pages.

One great thing with this method is that you can output an xml datasource with complex groups (with multiple Munchian groups in a row). With symphony datasource editor, you have the option to filter by, group by, but you cannot group with multiple levels. (You probably can if you know well mysql and php, which is not my case).

It s not a standard way to use symphony and probably a bit heavy for the server sometimes (and remote datasources cache delay) but it is interesting: on top of that I have added members extension so members can modify their pages if they match the contact info of the page. They can enrich their basic contact info page with personalized content creating standard symphony entries. But when the admin of the site change the contact info in the excel file, then it reassign rights of the members, and can assign rights to inexistent users (virtual future members) without having to manage every member or entries of a section one by one.

Sorry for this long and complicated post :-p

@vincentd - Thanks for sharing. If you have time, would you mind doing a quick screencast (video) about your process to show this in action? I am curious to see how it works.

Sure I will, as soon as it is finished (still working on the personalized content), in about 10 days I think. Today the same client requested a new development with the same idea of rendering from Excel file. So it can be interesting for your clients too if you think it is sustainable, it clearly depends on the amount of data.

Funny, I have started using Excel 2004 XML worksheets (on PCs it is called XML Calculation Table 2003 or similar, sorry, I only know the German name…) a lot! It's a pretty good import/export format (at least better than CSV)!

Yes not so bad, full of parameters needed for Excel, so the XML looks a bit ugly the first time but it keeps the colors of the cells. Working on Mac and my client Mac and PC. On mac the CSV export from Excel is not utf8 encoded, so it was not an option.

@bzerangue, here is a screencast the password to watch it is excelsymphony

@vincentd:

This is a very, very cool screencast, and you did a great job with that website!

Thanks for your work on the screencast, it must have taken some time… and it is full of ideas and a great advertisement for Symphony.

Coming from one the most active member here, I am really flattered :-D

Development of this website was a hard work indeed, mostly due to the complexity of the subject (french unions is quite complex to understand and this one is not a simple union, but a federation of autonomous unions... anyway). Launch is planned in 2 months (time for the client to review and double check all features and for me to debug, if they find anything). I will tell you when you can see it on production.

Symphony is the most powerful and flexible cms I found, thanks to Allen Chang, Alistair Kearney and all the core team, what you did and what you do everyday is great.

@vincentd - Well done! Very cool stuff. Thanks for sharing with us!

Also, how were you outputting your JSON on the /api/ pages you were generating on the screencast?

Thanks :-)

I read in the forum it is not the best approach (in a post about api page extension probably, which I couldn't use because it's not working with latest symphony versions), so the json is generated by xsl templates, very very basic loops <for-each> <call-template> <value-of> and <xsl:if test="position()!=last()">,</xsl:if> ...nothing but noob code.

The formatting of the json arrays is mostly done by the xml datasource of this page (remote datasource coming from the "xml" page) with multi muenchian groups.

And content type mapping extension.

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