Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 11, 2011 @ 15:24
    Fuji Kusaka
    0

    XSLT Paging in editor not working

    Hi guys,

    I have a news XSLT where there is about 20items being displayed monthly and to make this more user friendly i added a pagintor but its not showing up. To this has anything to do with the fact that am using the macros in the eidtor?

    here is the piece of code am using

    <xsl:variable name="source" select="/macro/source"/>
    <xsl:variable name="itemsToDisplay" select="10"/>
    <xsl:variable name="numberOfItems" select="count($currentPage/* [@isDoc and string(umbracoNaviHide) != '1'])"/>
        
    <!-- Paging -->
    <xsl:variable name="pageNumber">
      <xsl:choose>
        <xsl:when test="umbraco.library:RequestQueryString('page') = ''">
          <xsl:value-of select="1"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="umbraco.library:RequestQueryString('page')"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>    
        
    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul class="eventList">
    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
       <xsl:sort select="current()/eventDate" order="descending"/>
          <xsl:if test="position () &lt;= $itemsToDisplay">
            <li class="eventLink">
                  <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="eventTitle"/> </a>
            </li>
            <li style="padding-left:15px; font-style:italic;"> <!--<em style="font-size:10px;"><xsl:value-of select="umbraco.library:FormatDateTime(./eventDate, 'd MMMM, yyyy')" disable-output-escaping="yes"/> </em>    <br/>-->
               <xsl:value-of select="umbraco.library:TruncateString(eventDescription,250,'...')" disable-output-escaping="yes"/>
            </li>
          </xsl:if>
    </xsl:for-each>
    </ul>
      
      <xsl:if test="$pageNumber &gt; 1">
      <a href="?page={$pageNumber -1}#events">previous &nbsp;</a>
    </xsl:if>
      
      <xsl:call-template name="for.loop">
      <xsl:with-param name="i"> 1 </xsl:with-param>
      <xsl:with-param name="count" select="ceiling($numberOfItems div $itemsToDisplay)"></xsl:with-param>
    </xsl:call-template>  
      
    <xsl:if test="(($pageNumber) * $itemsToDisplay) &lt; ($numberOfItems)">
      <a href="?page={$pageNumber+1}#events">&nbsp; next</a>
    </xsl:if>
      
      </xsl:template>
      
        <xsl:template name="for.loop">
                    <xsl:param name="i"/>
                    <xsl:param name="count"/>
                    
                    <xsl:if test="$i &lt;=$count">
                            <xsl:if test="$pageNumber!= $i">
                                    <a href="?page={$i}#events"><xsl:value-of select="$i" />&nbsp;</a>
                            </xsl:if>

                            <xsl:if test="$pageNumber = $i">
                                     <xsl:value-of select="$i"/>&nbsp;
                            </xsl:if>

                            <xsl:call-template name="for.loop">
                                    <xsl:with-param name="i" select="$i + 1" />
                                    <xsl:with-param name="count" select="$count">
                                    </xsl:with-param>
                            </xsl:call-template>
                    </xsl:if>

    </xsl:template>

     

     


    //fuji

  • Stuart Burrows 61 posts 110 karma points
    Jul 11, 2011 @ 15:50
    Stuart Burrows
    0

    What do you mean you are using it in the editor?

    You can't just visualise this xslt since you are pulling a variable from the macro - what happens when you change the source variable from a macro value to an existing page id?

    If its not this please advise what happens - does nothing appear at all or just no pagination?

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jul 11, 2011 @ 15:55
    Sebastiaan Janssen
    0

    You shouldn't put a paging macro in the rich text editor, put it in your template instead. 

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 11, 2011 @ 19:22
    Fuji Kusaka
    0

    Hi Sebastiaan,

     

    Yes am using my macro in editor to pull the data since am using the same template all over the website. So you recommend not to use macro in editor?... can I you why this is not recommended?

     

    //fuji

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jul 11, 2011 @ 19:28
    Sebastiaan Janssen
    0

    You don't want your editors to have to decide what macro's are in your pages. They should just create a page of some type and get all the other stuff for free. Besides, it's very error prone to do this.

    Inserting macro's in a rich text editor should always be a last resort when you really HAVE to have something dynamic in the middle of some content somewhere, maybe. Even then, I would try and split it up into two editors and a macro picker in the middle somewhere.

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 11, 2011 @ 19:51
    Fuji Kusaka
    0

    You are right....good point but you wouldnt even recommend accessing media content using macros in editor?.....

    Lets say the user can actually creates and crop its images in the media section and then from the content when creating a new album (node) access the media folder using a macro in the editor.


    //fuji

  • Rich Green 2246 posts 4008 karma points
    Jul 11, 2011 @ 19:59
    Rich Green
    0

    Hey,

    I'm with Sebastiaan on this, I avoid allowing Macros in the RTE unless 100% necessary, in fact I turn off as many of the RTE toolbar items as I can get away with.

    Inserting media can be ok, but if the layout is consistent and you know where the image is going then imho it's better to have the user select this image via a DocType property and then let your xslt/razor/template display the image.

    Rich

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 11, 2011 @ 20:07
    Fuji Kusaka
    0

    Hi Rich,

    Yes i do agree with both of you, it is not a good thing to give full access to client then you find yourself cleaning all the mess.

    For the media part am only using it this way so as to allow the client to acess any of hes created media item since this will end up as a slideshow when he will be browsing. But what if he has like 100 images?..

     

    //fuji

  • Rich Green 2246 posts 4008 karma points
    Jul 11, 2011 @ 20:14
    Rich Green
    0

    I'm not sure what you mean, are you picking images for a slideslow in the RTE?

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 11, 2011 @ 20:23
    Fuji Kusaka
    0

    Yes am picking images using mediacurrent, you might be asking yourself why?

    Well its only because the client wants to be able to create a new album (node)under the Photo Gallery section and from there br able to acess the media section.

     

     

  • Rich Green 2246 posts 4008 karma points
    Jul 11, 2011 @ 20:36
    Rich Green
    0

    I'm still not 100% but I'm going to guess that you need to your client to pick 20 images from the media section and display them in a slideshow?

    If this is the case then you can just use the http://ucomponents.codeplex.com/wikipage?title=MultiNodeTreePicker&referringTitle=Documentation and set it to media, then your client can pick 20 images and have a preview too.

    I think this thread has gone a little off topic, maybe my fault!

    Rich

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 11, 2011 @ 20:40
    Fuji Kusaka
    0

    No worries, i wanted to know if it was possible to make a paging work in RTE.

    Its always good to get the best advise.

    //fuji

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 13, 2011 @ 15:54
    Fuji Kusaka
    0

    Hey Rich,

    Am back working on the project and did implement the macro in template instead of RTE. Everything is working except for the part where i need to go to the next page. The content of my page is not changing at all, i can see from the url that it is working but not for the content.

    Is there something am missing?

     

    //fuji

  • Stuart Burrows 61 posts 110 karma points
    Jul 13, 2011 @ 16:11
    Stuart Burrows
    1

    I can't see where you are changing your output based on your paging results. I would have thought that this:

     

    <xsl:if test="position () &lt;= $itemsToDisplay">

    should look something like this:

    <xsl:variable name="example" select="$itemsToDisplay * $pageNumber" />
    <xsl:if test="position() &lt;= $example and position() &gt;= ($example - $itemsToDisplay)">

     

     

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 13, 2011 @ 16:34
    Fuji Kusaka
    0

    Hi Stuart,

     

    Thanks for the help got it working.

     

    //fuji

Please Sign in or register to post replies

Write your reply to:

Draft