Copied to clipboard

Flag this post as spam?

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


  • kukuwka 75 posts 96 karma points
    Oct 12, 2010 @ 13:35
    kukuwka
    0

    umbraco.library:Replace dosn't work

    Hi,

    I have url and QueryString like :
    http://domain/page?categoryId =2560&subcategoey=7777


    <xsl:variable name="oldCategory">

       categoryId=<xsl:value-of select="$categoryId"/>

    </xsl:variable>

     

    <xsl:variable name="newCategory">

       categoryId=9999
    </xsl:variable>

     

    <xsl:variable name="url">

        <xsl:value-of select="umbraco.library:Replace($searchUrl, $oldCategory, $newCategory)"/>

    </xsl:variable>

    but url remains the same.

    How can I change url?

    Thanks,

    kukuwka

  • Rich Green 2246 posts 4008 karma points
    Oct 12, 2010 @ 13:49
    Rich Green
    0

    What output do you get when you add these to your XSLT?

    Search: <xsl:value-of select="$searchUrl"/> 
    <br/>
    
    Old: <xsl:value-of select="$oldCategory"/>
    <br/>
    
    New: <xsl:value-of select="$newCategory"/>
    
    Rich
  • kukuwka 75 posts 96 karma points
    Oct 12, 2010 @ 14:02
    kukuwka
    0

    I get right values.

    Old: categoryId=2560

    New :categoryId=9999

     

  • Rich Green 2246 posts 4008 karma points
    Oct 12, 2010 @ 14:05
    Rich Green
    0

    And searchUrl, maybe you could post your whole XSLT here?

    The replace function certainly does work, so something simple must be wrong.

    Rich

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Oct 12, 2010 @ 14:14
    Lee Kelleher
    1

    Hi kukuwka,

    I think the Replace function might not like the value of the $oldCategory and $newCategory variables - probably due to the whitespace/character-data.

    Instead of using <xsl:value-of> inside the <xsl:variable> tags - try using the select?

    <xsl:variable name="oldCategory" select="concat('categoryId=', $categoryId)" />
    <xsl:variable name="newCategory" select="string('categoryId=9999')" />
    <xsl:variable name="url" select="umbraco.library:Replace($searchUrl, $oldCategory, $newCategory)" />

    Let us know if that works out.

    Cheers, Lee.

  • kukuwka 75 posts 96 karma points
    Oct 12, 2010 @ 14:19
    kukuwka
    0

    This is my code:

    <xsl:variable name="searchUrl" select="/macro/searchUrl"/>
    <xsl:variable name="categoryId" select="umbraco.library:RequestQueryString('categoryId')"/>

    <xsl:variable name="oldCategory">

        categoryId=<xsl:value-of select="$categoryId"/>

    </xsl:variable>


    <xsl:for-each select="$items">

          <xsl:variable name="newCategory">

                   categoryId=<xsl:value-of select="@id"/>

          </xsl:variable>


          <xsl:variable name="url">
            
                   < xsl:value-of select="umbraco.library:Replace($searchUrl, $oldCategory, $newCategory)"/>

           </xsl:variable>
         

         <a href="{$url}">
           
                  <xsl:value-of select="$nodeName"/>

         </a>

    </xsl:for-each>

     

     

    Thanks,

    kukuwka

  • kukuwka 75 posts 96 karma points
    Oct 12, 2010 @ 14:29
    kukuwka
    0

    Hi Lee,

    Thank you very much.

    It works.

Please Sign in or register to post replies

Write your reply to:

Draft