Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 5 of 5

Thread: If Statement in XML Package

  1. #1
    apastue@kingpar.com is offline Junior Member
    Join Date
    Nov 2009
    Location
    Michigan
    Posts
    20

    Default If Statement in XML Package

    I am trying to diplay a topics page through my category XML package based on which category is selected.

    For example
    If category 5 is selected
    show topics page 5

    I have tried this code and I get an error

    <xsl:choose>
    <xsl:when test="$CurrentEntityNode">
    <div>
    <xsl:if test="@categoryId = '10'"><xsl:value-of select="aspdnsf:Topic('cattpage.drivertop')" disable-output-escaping="yes"/></xsl:if>
    <xsl:if test="@categoryId = '11'"><xsl:value-of select="aspdnsf:Topic('cattpage.driverbottom')" disable-output-escaping="yes"/></xsl:if></div>
    </xsl:when>
    <xsltherwise>
    <div><xsl:value-of select="aspdnsf:Topic('SearchPageHeader')" disable-output-escaping="yes" /></div>
    </xsltherwise>
    </xsl:choose>
    Thank you,

    Andrew Pastue
    http://www.kingparsuperstore.com

  2. #2
    jsimacek is offline Senior Member
    Join Date
    Dec 2008
    Location
    Phoenix, AZ
    Posts
    373

    Default

    What's the exact error you are getting? Are you variables all declared and set?
    Jan Simacek - Compunix, LLC
    AspDotNetStorefront trusted Devnet Partner and Reseller since 2005

    AspDotNetStorefront Mods and Add-Ons at http://www.ecommercecartmods.com/
    - Searching, Filtering and Sorting (like cSearch, Dealer Locator, Price Ranges, Blog)
    - Reports (like Cart Abandonment and Net Sales)
    - Customer Experience (like Question/Answers)
    - Site and Data Management (like Entity Product Mapper, Bulk Updaters, Make/Model/Year filters)

  3. #3
    apastue@kingpar.com is offline Junior Member
    Join Date
    Nov 2009
    Location
    Michigan
    Posts
    20

    Default

    My mistake. I am not getting an error. Just no results.

    Thank you for your reply.

    Andrew
    Thank you,

    Andrew Pastue
    http://www.kingparsuperstore.com

  4. #4
    apastue@kingpar.com is offline Junior Member
    Join Date
    Nov 2009
    Location
    Michigan
    Posts
    20

    Red face Help with If than in XML Package

    I just want a simple way to load one topics page over another based on what category you are in.

    My guess is this would be call through the XML package and I assumed it would use an if thank or case statement.

    Please help if you can.

    Thank you

    Andrew P.
    Thank you,

    Andrew Pastue
    http://www.kingparsuperstore.com

  5. #5
    lehmans is offline Junior Member
    Join Date
    Jun 2012
    Location
    Dalton, OH
    Posts
    12

    Thumbs up

    What is your variable "$CurrentEntityNode" set to?

    If you want to use an if then statement you could do something like:

    <xsl:variable name="categoryID" select="/root/Runtime/EntityID" />

    <xsl:choose>
    <xsl:when test="$categoryID = 10">
    <xsl:value-of select="aspdnsf:Topic('cattpage.drivertop')" disable-output-escaping="yes" />
    </xsl:when>
    <xsl:when test="$categoryID = 11">
    <xsl:value-of select="aspdnsf:Topic('cattpage.driverbottom')" disable-output-escaping="yes" />
    </xsl:when>
    <xsltherwise>
    <div><xsl:value-of select="aspdnsf:Topic('SearchPageHeader')" disable-output-escaping="yes" /></div>
    </xsltherwise>
    </xsl:choose>


    If it was me I would rename your topics to include the category id that you want it to be used on. So for example rename "cattpage.drivertop" to "cattpage.10". Then you could just use the following code and would never have to change the code for each different category which makes your code more dynamic:

    <xsl:variable name="topicName" select="concat('cattpage.', /root/Runtime/EntityID)" />
    <xsl:variable name="topicContents" select="aspdnsf:Topic($topicName)" />

    <xsl:choose>
    <xsl:when test="string-length($topicContents) &gt; 0">
    <xsl:value-of select="$topicContents" disable-output-escaping="yes" />
    </xsl:when>
    <xsltherwise>
    <xsl:value-of select="aspdnsf:Topic('SearchPageHeader')" disable-output-escaping="yes" />
    </xsltherwise>
    </xsl:choose>