Search

I am configuring Symphony CMS to provide a backend for Flash sites; I think this CMS is a good solutions for this. I am trying to figure out the following; since Flash takes XML as input, is it necessary to define XSLT templates? I mean, Symphony CMS already has XML as standard output. Is there a way I can use this standard output?

Yes indeed. You’ll still need to write a little bit of XSLT, but using the copy-of element you can literally copy XML and render it as-is:

  • create a new Page
  • add XML in the Page Type field (to send text/xml headers, not text/html)

Then edit your page XSLT to look like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />

<xsl:template match="/">
    <xsl:copy-of select="data"/>
</xsl:template>

</xsl:stylesheet>

This will output the root data node.

If you’re sending POSTs from Symphony, you can modify the above to just output the response from a specific event:

<xsl:copy-of select="events/save-comment"/>

I just found Symphony yesterday and I also think this can be a great CMS for Flash websites. Ideally would be to make something that outputs html for folks without Flash and special xml for flash + integration with SWFAddress.

I’ll start building next week. Will take some time, cuz I haven’t wrapped my head around the whole xslt language. But it doesn’t seem too hard.

@jedw: can you share your progress?

EDIT: Seems like integration with GAIA is the way to go.. http://getsymphony.com/discuss/thread/31414/2

@vknt sure I will keep you posted. I already have set up a pilot site with GAIA. GAIA indeed is the way to go. Not only will it save you lots of time by scaffolding, navigation, preloading etc. but also it has all the dynamic reading of assets from XML readily setup.

What I need to get done is the following:

I have several items; for instance “People” - I have a section consisting of a Name and a Position input field - And I have a Data Source “People” with the “People” section as source and I make it output the parameter System ID

And than I have a “generic” section “Images” which consists of a file upload field and a “Show With” Select Box Link.

By this means, images can be added and linked to a specific other section (such as “People”).

Than I create a “People Images” Data Source and I put $ds-people as a filter. Finally I create a page People with People and People Images as sources.

The result is a XML output with all people data (Name and Title) following with all People Images. Only the images associated with People are included.

The result I want to have is as following:

<people>
  <person>
    <name>Person X</name>
    <position>Position X</position>
    <image>IMG_XXX.jpg</image>
  </person>
  <person>
    ...
  </person>
</people>

Question: do I need to structure this all using XSLT or can I make some improvements in my set up in Symphony. Hope this is clear! Thanks in advance.

Provided your two Data Sources are outputting the correct data (which they seem to be) the best way is to write some XSLT to combine the XML together.

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output encoding="UTF-8" indent="yes" method="xml" />

<xsl:template match="data">
    <people>
        <xsl:apply-templates select="people/entry" mode="person"/>
    </people>
</xsl:template>

<xsl:template match="entry" mode="person">
    <person>
        <xsl:copy-of select="name"/>
        <xsl:copy-of select="position"/>
        <xsl:apply-templates select="/data/person-images/entry[person/@link-id = current()/@id]" mode="image"/>
    </person>
</xsl:template>

<xsl:template match="entry" mode="image">
    <image>
        <xsl:copy-of select="image-upload"/>
    </image>
</xsl:template>

</xsl:stylesheet>

The top template matches on the root data node. It writes out the containing people and then applies the person template on each entry from your people Data Source. The next template writes out each person and then applies the last template finding any entries in the person-images DS where the person ID matches up.

The names and XPath I’ve used might not match your example exactly, but should be enough to get you started.

how do I use this method to make and actual .xml file located in a directory on the server?

I’m sorry but you can’t create files using Symphony’s pages. Everything they do is control the output of your content to the browser.

Can you specify, why exactly you want to save an XML file to the servers disc?

To save the output as an .xml file you will need to write an Extension that provides an Event. I wouldn’t recommend doing this for someone just starting out with Symphony as it explores some pretty advanced concepts.

Currently I am using this line to output the absolute path to an image:

<image><xsl:value-of select="$workspace"/><xsl:value-of select="image-file/@path"/>/<xsl:value-of select="image-file/filename"/></image>

I’m sure this can be done more elegantly? XSLT can be pretty hard to wrap your head around! Any hints?

I’m having a tough time with 2 concepts of xslt / xml uses. problem 1, I need an xml file for slideshow pro to pull the data for the photos and text I want to show in the slideshow. not sure how to point in in the hidden xml page I’ve generated. I can point the browser to it (myweb.com/page/images/) and see the xml just fine, just need to link it to slideshow. 2nd problem is my pages don’t have actual page names such as myweb.com/page.html they just show as myweb.com/page/ if I can figure that out I’ll probably be set. Thanks guys for all your help so far. This Symphony system is very cool…

I’m sure this can be done more elegantly?

@jedw, give this a try:

 <image><xsl:value-of select="concat($workspace, image-file/@path, '/', image-file/filename)"/></image>

@carsten Thank you! That was where I was looking for. Finished my first XSLT template; implemented the Image Cropper extension (which is great). Symphony CMS is really powerful! Code:

    <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8" indent="yes"/>
    <xsl:template match="data">
        <brands>
            <xsl:apply-templates select="brands/name/entry" mode="brand"/>
        </brands>
    </xsl:template>
    <xsl:template match="entry" mode="brand">
        <brand>
            <xsl:copy-of select="name"/>
            <xsl:copy-of select="url"/>
            <images>
                <xsl:apply-templates select="/data/brand-images/entry[show-with/item/@id = current()/@id]" mode="image"/>
            </images>
        </brand>
    </xsl:template>
    <xsl:template match="entry" mode="image">
        <xsl:choose>
            <xsl:when test="crop/@cropped = 'yes'">
<!-- jCrop mode of JIT expects a url like /image/4/crop_width/crop_height/crop_x/crop_y/resize_width/resize_height/path/to/image.jpg -->
                <image>
                    <xsl:value-of select="concat($root, '/image/4/', crop/@width, '/', crop/@height, '/', crop/@x1, '/', crop/@y1, '/', crop/@width, '/', crop/@height, image-file/@path, '/', image-file/filename)"/>
                </image>
            </xsl:when>
            <xsl:otherwise>
                <image>
                    <xsl:value-of select="concat($workspace, image-file/@path, '/', image-file/filename)"/>
                </image>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>

This post/you guys/this project is amazing…. absolutely amazing.

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