Search

@ahwayakchih, I hope you don't mind me mentioning this extension, but I was looking around github to see what people were up to as far as extension development goes, and I came across your work on the Improved Page Resolve extension. The ability to have the index page parameters resolve without the need for the page parameter is something that a number of people have asked for in the past. Thanks for developing this.

It now allows for a home page with year/month/day/title URL parameters for URLs like this:

www.example.com/2009/03/26/my-entry-title/

Without your extension, this was not possible without creating a page for the year 2009.

Now, I'm playing around with the idea of dynamically displaying entries with a/b/c URL parameters using a template like this:

<xsl:template match="/">
    <xsl:param name="entry">
        <xsl:choose>
            <xsl:when test="$a">
                <xsl:copy-of select="data/sections/entry[title/@handle = $a]"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:copy-of select="data/sections/entry[title/@handle = $current-page]"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:param>
    <html>
        <head>
            <title><xsl:value-of select="$entry/title"/></title>
        </head>
        <body>
            <h1><xsl:value-of select="$entry/title"/></h1>
        </body>
    </html>
</xsl:template>

The problem, however, is that with XSLT 1.0, xsl:copy-of returns a result tree fragment instead of a node-set, where XSLT 2.0 returns a node-set. Since PHP doesn't yet support XSLT 2.0, does anyone know of a way around this without installing EXSLT extensions?

By the way, the following template does work, demonstrating the possibility of a single page, single template site:

<?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"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    omit-xml-declaration="yes"
    encoding="UTF-8"
    indent="yes" />

<xsl:template match="/">
    <xsl:choose>
        <xsl:when test="$a">
            <xsl:for-each select="data/sections/entry[title/@handle = $a]">
                <html>
                    <head>
                        <title><xsl:value-of select="title"/></title>
                    </head>
                    <body>
                        <h1><xsl:value-of select="title"/></h1>
                        <p><xsl:copy-of select="description/*"/></p>
                    </body>
                </html>
            </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>
            <xsl:for-each select="data/sections/entry[title/@handle = $current-page]">
                <html>
                    <head>
                        <title><xsl:value-of select="title"/></title>
                    </head>
                    <body>
                        <h1><xsl:value-of select="title"/></h1>
                        <p><xsl:copy-of select="description/*"/></p>
                    </body>
                </html>
            </xsl:for-each>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

</xsl:stylesheet>

Most excellent!

bauhouse, i kept it "unreleased" because i'm waiting for Symphony developers decision to include such change to core or not. If it will not be included, i will release it "officially", with some additional changes (it will have own database table with pre-calculated stuff, so SQL query will be much simpler and faster).

I'm working on a site where each page (in URL sense, not Symphony Page) is actually regular entry. There is "pages" section and "content" section, where each entry in "content" section is linked to one or more entries in "pages" section. There's just one Symphony Page, with URL schema that looks like: page/entry :). Such set up makes it easy to add/remove various attributes to/from pages, define static content (like header graphic, change colors, meta, etc...) and everything else You can do with entries. It also makes it easier to add pages without knowledge about XSLT. Finally, it is easy to create multilingual site this way (with URLs in different languages :).

There is one (well... so far :) disadvantage: index with parameters will catch all page requests with less than or equal number of nodes in URL. 404 error page will show up much less often, showing default index page instead (or many pages at the same time... depends on filters, default parameters, XSLT, etc... ;).

@ahwayakchih,

So, does this site you're working on have a deeper sitemap than 1 level? In other words, how do you avoid having to create another Symphony page if you need to create a sub-section with its own set of child pages?

ashooner site is quite simple, so all URLs are one level deep (page/content). Each entry in "pages" section can link to another entry in the same section to make it "parent" page. I use it only to render main menu and sub-menus, but i think the same set up could be used to have more than one level deep URLs, e.g, page/subpage/content. It would just require more data sources and/or some heavy filtering. Also adding more depth levels (page/subpage/subsubpage/content and page/subpage/subsubpage/subsubsubpage/content) would require adding data source and URL param for every depth level or manipulating parameters... or maybe filtering with simple parameter fall back would work, i.e.,

{$subsubsubpage:$subsubpage:$subpage:$page}

but i'm not sure - it's just a quick thought without any testing done before :).

@ahwayakchih

Awesome extension! I almost started writing the exact same thing myself… :-)

It would be nice to have a new Page type “fallback” to set the default Page independently from “index”…

@ashooner

I am not sure if its what you are looking for but i am using the Global Parameter Loader.

I am loading a param “current-uri” using return str_replace("/pages/","/",((strpos($_SERVER['REQUEST_URI'], "?") === false) ? $_SERVER['REQUEST_URI'] : substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], "?")))); and use it in my Data Source (the complicated PHP is necessary to remove possible ?param=value parameters).

For the index-page I’ve set up link1/link2/link3/link4/link5 as URL parameters without ever actually using them, just to enable up to 5 levels of sub-pages. :-)

All of a sudden the Extension is misbehaving… It’s passing every request to my index-Page although the Page exists. I will look into it.

Request: How about having the option to choose a custom pagetype for this to work on, instead of just index?

Darn, missed this post (ofcourse only after writing my own)..

my solution can be found here:

http://github.com/creativedutchmen/Root-Page-Params

the extension seems to have broken 404, it might be something else but i get problem forwarding to 404 error for some reason

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