Search

I have a Blog page on a website (with the URL Handle of “blog”), and following the tutorials on the Symphony website, I’m able to view the single post via the URL of:

/blog/entry/{title of blog entry}

Is there anyway at all for me too have the URL as:

/blog/{title of bog entry}?

If it’s any help, I have the “Blog Entry” page as a child element of the parent “Blog” page.

Cheers!

Is there anyway at all for me too have the URL as:
/blog/{title of bog entry}?

As far as I can tell, URL-parameters are optional by default in Symphony, so you can add the “title”-parameter directly to your “Blog”-page. If no title is given, the datasource outputs an unfiltered entries-list.

Everything else could be done with some XSLT-magic (different markup for entries-list and single-entry, for example).

This is called a Master Detail set, where you would indeed have an url-param called something like ‘title’ on your page.

You’d then need two datasources, one with minimal output to be used as a list, and one with all the output you need to make a detail view. This method will actually save on XML overhead, even though it sounds a little more XML…

In our detail datasource, make the required parameter the url-param of your page, which will suppress output unless it has a value. Also filter your datasource with this parameter.

To limit the output of the list, you can also filter it on the url-parameter, so that when you’re in detail view, there’s not too much XML overhead.

To get the page to display differently lies in your XSLT magic…

Hope this helps! I think this may need writing up as it seems to be a prefered method for URL structure in sites (and I seem to keep repeating it lol).

Sounds quite confusing to read at first! Can it be done with just the one data source though? I will need to do this on three or four sections, so it could become a bit messy.

If you could kindly provide a basic ensemble containing just this which I can install and see, or maybe a more in depth write up, then that would be great!

Cheers for the replies!

I personally don’t use /blog/{title-of-blog-entry}/, because it restricts you from having /blog/{page-number}/ for representing the subsequent pages of blog entries.. although if you aren’t planning on having more than one page it would make sense.

Yeah, it can definitely be done with one datasource… @jensscherbl said it all basically, 1 page, with an url-param, and 1 datasource filtered by that url-param.

So your page would be called Blog, with a handle of /blog, and you’d add an url param of post-title.

Create a datasource, called Blog Posts, and add a filter on the Title field, using the url-param like so

{$post-title}

Choose all of the fields to output that you want to use in the frontend display of the post. You can also set the number of posts to be displayed.

Now if you go to your /blog url and append ?debug (if you have the debug extensions enabled) you can see the full list of posts. If you enter the title of a post before ?debug at the end of your url and hit enter, you will see the list shrink to the single entry!

Now comes the XSLT. In your stylesheet, set the param at the top, so your template can fall back to it when it’s not set in the url…

<xsl:param name="post-title" />

With this you can now do a choose statement to output either a list or an entry, something like

<xsl:template match="data/blog-posts">
    <xsl:choose>
        <xsl:when test="$post-title != ''">
            <xsl:apply-templates select="entry" mode="single" />
        </xsl:when>
        <xsl:otherwise>
            <xsl:apply-templates select="entry" mode="list" />
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>
<xsl:template match="blog-posts/entry" mode="single">
    ... your single post code
</xsl:template>
<xsl:template match="blog-posts/entry" mode="list">
    ... your list of posts code
</xsl:template>

Filling in the templates with code you’ve learned from the tutorials.

I hope this helps :o)

Thanks! I’ve got it working now!

The only thing now is my blog comment event doesn’t work fully, it still works and posts correctly, but there is no success output in the HTML so I can’t display a message for the user. Does anyone have any idea’s why? I’ll have a play see if I can figure it!

I’ve not done front end input yet…

Ahh.. I’m trying to figure it, but it doesn’t seem to want to output the event in the HTML!

For starters try:

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

That’ll dump the XML for you to play with.

Cheers Nick. I have it working!

For some reason, making the blog like @designermonkey said, the XML of the event isn’t added in the ?debug area, or in the HTML of the page.

Cheers Nick. I have it working!

Good stuff.

the XML of the event isn’t added in the ?debug area

If you append ?debug to the URL after the form has posted then you’ll lose the POST data from the browser. But if you post the form directly to ?debug (add it to the form’s action attribute) then it will post and show you the result.

or in the HTML of the page.

In manfiest/config.php there’s a setting named display_event_xml_in_source which when set to yes will show the result of any Events in an HTML comment on the bottom of your page source. So rather than posting to ?debug you can just view source after submitting and see the result. (This is only shown when you’re logged in to Symphony.)

Before I changed the URL setup, it was displaying the event in the HTML, but since witching, the event is not displayed in the HTML. Obviously it’s still there as it’s in the XML and works how I want so I guess it’s all fine!

Glad it all works now…

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