Search

Hi everyone,

This if my first post in the symphony forum, I’ve used symphony on the past 3 websites I’ve done and am really enjoying it. So thanks to all the developers for making such a great CMS.

I’m having trouble with the best way to approach this.

I have a site with a list of links to coffee brewing methods (brewmethods.com)

I’m adding some basic functionality to it and I’d like it to have three different ‘views’ on the home page: 1. The brew methods are sorted by alphabet. 2. Sorted by date added. 3. Default.

The question I have is what is the best way to set this up?

I can easily get the XML organized the way I’d like it, but my question is what’s the best way to deliver the XML to the view. I’d like to only pass the desired XML, rather than pass all three sets of XML and then have to filter it with XSL.

Currently I have three data sources: alpha, latest, and default.

Thanks for reading, any help would be appreciated.

Use an URL param. ?view=alphabet ; ?view=date ; ?view=default.

Attach all 3 DSs to your page and execute each of them according to this parameter.

E.g.for DS alpha ( = workspace/data-sources/data.alpha.php):

Set return false in function allowEditorToParse() so Symphony won’t change your customization.

public function allowEditorToParse(){
    return false;
}

public function grab(&$param_pool=NULL){
    $result = new XMLElement($this->dsParamROOTELEMENT);

    if ( $this->_env['param']['url-view'] == 'alphabet' ) {
        try{
            ...
        }
    }
    else {
        $this->_force_empty_result = 1;
    }

    if($this->_force_empty_result) $result = $this->emptyXMLSet();
    return $result;
}

The same would be possible in XSLT as well, using the same XML for every case. This could give you a start:

<xsl:choose>
    <xsl:when test="$url-view = 'alphabet'">
        <xsl:apply-templates select="entry">
            <xsl:sort select="title/@handle"
                data-type="text"
                order="ascending"
                lang="en"/>
        </xsl:apply-templates>
    </xsl:when>
    <xsl:when test="$url-view = 'date'">
        <xsl:apply-templates select="entry">
            <xsl:sort select="concat(substring(date,1,4), substring(date,6,2), substring(date,9,2), substring(date/@time,1,2), substring(date/@time,4,2))"
                data-type="number"
                order="descending"/>
        </xsl:apply-templates>
    </xsl:when>
    <xsl:otherwise>
        <xsl:apply-templates select="entry"/>
    </xsl:otherwise>
</xsl:choose>

This solution is untested, and it doesn’t work with pagination, though.

[EDIT]: Corrected the code.

[EDIT2]: Tested this and fixed it.

Thanks for the quick responses, I’ll experiment and report back.

I'm terribly late, but I figure better late than never.

Thanks for the above replies, I got it working!

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