Copied to clipboard

Flag this post as spam?

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


  • Frederik T 241 posts 372 karma points
    Aug 16, 2011 @ 14:32
    Frederik T
    0

    Checking document boolean parameter in for-each loop

    Sorry for all the posts ive been making lately, hopefully this is easy enough to solve.

    The site im working on has a main page, of course, and about four sub sections.

    On the main page, and each sub section is a slider:
    http://codecanyon.net/item/jquery-list-style-rotator/133870

    That shows all the featured articles.

    To accomplish that, the parent document has a boolean property which purpose is to select wether or not its a featured article (as in, displayed in the list rotator on either front or sub section).

     

    Ok, now to the point.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:PS.XSLTsearch="urn:PS.XSLTsearch"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets PS.XSLTsearch ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <!-- start writing XSLT -->

    <div class="g640p10 none">
    <div class="container">
    <div class="l-rotator">

    <div class="screen">
    <noscript>
    <!-- when javascript is off -->
    <p>Javascript er ikke slÄet til.</p>
    </noscript>
    </div>

    <div class="thumbnails">
    <ul>
    <xsl:for-each select="$currentPage/descendant::*[@isDoc][not(umbracoNaviHide = 1)][articleFrontpageLink=true()]">

    <li>
    <div class="thumb">
    <img src="/ImageGen.ashx?image={DAMP[@fullMedia]/mediaItem/Image/umbracoFile}&amp;width=64&amp;height=64" alt=""/>
    <p>
    <span class="title">
    <xsl:value-of select="@nodeName"/>
    </span>
    <br/>
    <xsl:value-of select="umbraco.library:TruncateString(artikel-Teasertekst,70,'...')"/>
    </p>
    </div>
    <a href="/ImageGen.ashx?image={DAMP[@fullMedia]/mediaItem/Image/umbracoFile}&amp;width=600&amp;height=300"><xsl:value-of select="normalize-space('')"/></a>
    <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="normalize-space('')"/></a>
    <div style="top:5px; left:5px; width:325px; height:0;">
    <h1><xsl:value-of select="@nodeName"/></h1>
    <xsl:value-of select="umbraco.library:TruncateString(artikel-Teasertekst,160,'...')"/>
    </div>
    </li>

    </xsl:for-each>
    </ul>
    </div>

    </div> <!-- End .l-rotator -->
    </div> <!-- End .container -->
    </div> <!-- End g640p10 -->


    </xsl:template>

    </xsl:stylesheet>

    Since im still a newbie to this, and there wasnt any documentation i tried following the stock example that came with the slider and the above is the result.

    Its very, very ugly code i know, but it works, except for one thing (ok, two things, images doesnt work).

    The linking, and the articles text works but EVERY article on the entire site is displayed.

    <xsl:for-each select="$currentPage/descendant::*[@isDoc][not(umbracoNaviHide = 1)][articleFrontpageLink=true()]">

    The select, is supposed to only take those which property "articleFrontpageLink" is set to true. But like i said it displays everything regardless of the boolean.

    Ive tried several ways of writing the select statement with no correct results.

    It seems so simple but i cant get it to work, sigh, learning umbraco is really an uphill strugle (im not giving up though)

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Aug 16, 2011 @ 15:09
    Dan Diplo
    1

    How is articleFrontpageLink stored if you look in your Umbraco.config file? It may be stored as '0' or '1' rather than as a true bolean value, so you may need to change articleFrontpageLink=true() to string(articleFrontpageLink) = '1'


  • Frederik T 241 posts 372 karma points
    Aug 16, 2011 @ 15:24
    Frederik T
    0

    Oh man i feel so incredibly stupid. It worked. I was so sure it was "true/false". The properties type is set to "True/False" in the document template. So thats why i thought it was not a number.

     

    well, thank you very much, now i have a whole new heap of other things to fix. I will write them here for a while if anyone wishes to help, otherwise i will mark dan Diplo's post as solution.

    -The picture in the "href" doesnt work for obvious reasons. I figured i should exclude the picture finding to a template and apply the template or something like that. Sadly it looks like im FORCED to display the image this way due to how the slider works. cant find any other solutions.

    -a method on having an article ONLY featured on the main page of a sub section and not the main front page slider. The documents already have a seperate property for this.

    -cleaning up code. still trying to learn how to use xsl:template because that will clean up the code considerably.

     

    Anyway, thank you again Dan Diplo :)

Please Sign in or register to post replies

Write your reply to:

Draft