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

Search

I apolize another time for so many asking and not giving back anything to this community. I asked so much because I want to learn how Symphony and because there are not so many tutorials the only way for me is trying and asking if I don't understand something. Im not a expert in Symphony or xslt/xml. You are doing things I don't try because there out of my lequau.

Because some people asked how I solved the problem of displaying particular number of articles on a page I will give the script but I don't test it good so there can be error's in it.

The script is :

<?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:param name="page" />

<xsl:param name="month""/>


<xsl:variable name="articlesperpage">
<xsl:choose>
<xsl:when test="$page='1' and $month='2005-02' ">3</xsl:when>
<xsl:otherwise>2</xsl:otherwise>
</xsl:choose>
</xsl:variable>



<xsl:variable name="totpages">
<xsl:choose>
<xsl:when test=" $month='2005-02">2</xsl:when>
<xsl:otherwise>2</xsl:otherwise>
</xsl:choose>
</xsl:variable>



<xsl:variable name="offset">
<xsl:choose>
<xsl:when test=" $page=1 $month='2005-02">0</xsl:when>
<xsl:otherwise>3</xsl:otherwise>
</xsl:choose>
</xsl:variable>





<xsl:template match="/">
  <xsl:apply-templates select="/data/test/entry"/>

  <xsl:apply-templates select="besturing" />
</xsl:template>


<xsl:template match="/">
<xsl:template match="/">
<xsl:if (position()>='offset' and postition() >= 'offset+articlesperpage') >

<h1><xsl:value-of select="titel"/></h1><br />
    <xsl:value-of select="datum" /><br />
    <xsl:value-of select="tekst" /> <br />
</xsl:if>

</xsl:template>



<xsl:template match="besturing">
 <xsl:if test="$Page &gt; 1 and
          $Page &lt; $totalPages"> !j </xsl:if>
      <xsl:if test="$Page &lt; $totalPages">
      <!-- here the links for next

      /xsl:if>
      <xsl:when test="$Page eq 2">
           <!-- here the links for the previous 

</xsl:template




</xsl:stylesheet>

I hope we can work together in the future and I can make the site as I have in my head. I think Symphony is the only cms who can.

To be honest I can't really understand what you are after, I don't think this code will work, because it's not well-formed and there are logical and syntactical mistakes in it. It seems to me like a rather complicated way of doing something simple.

I think you should dive a little deeper in the concept of datasource filtering, chaining and pagination. also have a look at the pagination utility by nickdunn: it provides easy and integrated worry-free pagination of datasources.

Don't get me wrong: I don't want to sound like the first-of-the class nerd, but in order to help you need to first get a better understanding of how Symphony and XSLT works.

nanymor hit the nail on the head. Take another look over your code and you'll find a number of errors:

  1. <xsl:when test=" $month='2005-02">2</xsl:when> is missing the '.
  2. <xsl:when test=" $page=1 $month='2005-02">0</xsl:when> is missing an and and the '.
  3. You have an extra <xsl:template match="/">.
  4. <xsl:if (position()>='offset' and postition() >= 'offset+articlesperpage') > is all sorts of wrong. Missing test=", you've got a typo in position(), you have just used strings instead of $offset.
  5. <xsl:if test="$Page &lt; $totalPages">. The variables $Page and $totalPages don't exist, you've declared $page and $totpages instead.
  6. /xsl:if> is missing the <.
  7. <xsl:when test="$Page eq 2"> doesn't have a closing </xsl:when> and futhermore, there isn't a <xsl:choose> in sight.
  8. </xsl:template is missing a />.

That's 8 mistakes in a minute.

Because some people asked how I solved the problem of displaying particular number of articles on a page I will give the script but I don't test it good so there can be error's in it.

That's slack. Don't give a script if you are trying to help without testing it. Especially when we aren't talking one or two typos, but a mess. It's not helpful to the community and is a waste of time.

I admire your persistence, but I think you need to slow down and get the basics of XPath and XSLT sorted. I recommend XSLT 1.0 Pocket Reference, which I personally used when learning XSLT for Symphony. W3Schools gets a bad rap, and I'm expecting at least one person to want to shoot me, but they have an XPath and XSLT Tutorial that you should read.

@roelof - you also might search XSLT video tutorials. There are several on YouTube and some in the Symphony Vimeo group.

Just shot Brendo for posting links to W3Schools

If you're buying books, don't forget to add this to your cart: http://www.amazon.com/XSLT-Programmers-Reference-2nd-Michael/dp/1861005067

It is focussed on XSLT 2.0, but also contains all XSLT 1.0 and XPath 1.0 elements and functions. I find it very useful if I need to find information on a specific tag / function.

Fair. I will look into the references you gave me. And then try to rewrite a solution to this problem. And I don't think it's simple because I find no other cms who can do this.

@roelof

Are you sure you don't want to hire someone to build the site for you? I'm sure it will save a lot of your time and others as well.

And I don't think it's simple because I find no other cms who can do this.

I think you should consider hiring someone like vladG suggested, cms don't "do" things, they allow you to do things, some more, some less easily.

Most of the people in this forum are professional web-developers and so our conversations are targeted to this audience; if you just want to build your own blog probably Symphony is not a good choice, because it involves investing time and effort in a somehow steep learning curve, which is worth only if you are planning to make a living out of it.

Hello,

Here the better and tested xslt :

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

<xsl:import href="../utilities/master.xsl"/>
<xsl:import href="../utilities/dagboek-article.xsl"/>

<xsl:param name="total_articles" select="data/dagboek/pagination/@total-entries" />

<xsl:param name="articles_per_page">
    <xsl:choose>
        <xsl:when test="$page = 1 and $year = 2005 and $month = 04">1</xsl:when>
        <xsl:otherwise>4</xsl:otherwise>
    </xsl:choose>
</xsl:param>

<xsl:param name="number_pages">
    <xsl:choose>
        <xsl:when test="$year = 2005 and $month = 04">3</xsl:when>
        <xsl:otherwise>
           <xsl:value-of select="ceiling($total_articles div $articles_per_page)" />
        </xsl:otherwise>
    </xsl:choose>
</xsl:param>

<xsl:param name="offset">
    <xsl:choose>
        <xsl:when test="$page = 1 and $year = 2005 and $month = 04">0</xsl:when>
        <xsl:when test="$page &gt; 1 and $year = 2005"><xsl:value-of select="($page - 1)* $articles_per_page - 3" /> </xsl:when>
        <xsl:otherwise>
           <xsl:value-of select="$articles_per_page * $page  - $articles_per_page " />
        </xsl:otherwise>
    </xsl:choose>
</xsl:param>

<xsl:param name="end" select="$offset + $articles_per_page + 1" />

<xsl:template match="data">
<xsl:if test="$page &lt;= $number_pages" >
       <xsl:apply-templates select="dagboek/entry[position() &gt; $offset and position() &lt; $end]
 " />
</xsl:if>
<xsl:if test="$page &gt; $number_pages">
   <xsl:call-template name="error" />
</xsl:if>

<xsl:if test="$number_pages &gt; 1">
   <div class="post-nav">
          <xsl:if test=" $page &gt; 1" >
               <span class="previous"><a href="{$root}/dagboek/{$year}/{$month}/{$page - 1}"></a>

          </span>
          </xsl:if>
        <xsl:if test="$page &lt; $number_pages" > 
           <span class="next"><a href="{$root}/dagboek/{$year}/{$month}/{$page + 1}"></a></span>
        </xsl:if>
</div>
</xsl:if>


</xsl:template>


</xsl:stylesheet

Roelof

I still fail to see what this template does besides calculate some parameters. Also, what's so special about 2005/04 that you have to hard-code several exceptions for it?

Are you sure you've checked the section on limiting and pagination in the help docs? It seems you're trying to achieve something that DataSources do out of the box.

It does some calculation based on the month and year. So you can decide that on april 2005 on page 1 one article is displayed and one page 2,3 four articles are displayed. On month where on every page the same amount of articles are displayed this xslt script takes care of it.

It maybe can be done with datasources but then I fail to see how with only using the page-number in the url and not anywhere else you can do the same.

I also don't see how with datasources I can make that on let's say on page 2 you only want to display articles 2,3,4.

Ah, I see.

I'd fear though that showing only one article on the first page and 4 articles on the following pages wouldn't feel like "pagination" to my users.

Perhaps I would design it to be more like a "teaser" and then regular pagination on the following pages, effectively showing the teaser-article twice (both on the teaser page and then in the regularily paginated page for the month). This could also potentially result in a cleaner DS- and XSLT-structure.

Anyways, glad you got your problem sorted out.

Oke, And how would you do it like april 2005. I have then 1 big article on the first page and e few small on the rest. Or like febr. 2005 where there are only 3 small articles.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details