Copied to clipboard

Flag this post as spam?

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


  • Vishmay 19 posts 100 karma points
    Jan 31, 2017 @ 07:05
    Vishmay
    0

    xslt generate html without transformation

    I want to create own link picker to select link from umbraco usign macro with xslt, I have given option to select link by content picker

    Now after selecting link and other querystring parameter, I want Macro to generate html like

     <a data-id="1136" href="/{localLink:1136}?id=1" title="" class="readmore_btn small"> order </a>
    

    so that we can place it in rte and then it will be changed to relative url by front end

    the code snippet is

        <xsl:param name="selectedPage" select="/macro/selectedPage"/>
    <xsl:param name="QueryString" select="/macro/QueryString"/>
    <xsl:variable name="Link" select="concat('/{localLink:' , $selectedPage , '}' , '?' ,$QueryString)"/>
    
    <a data-id="{$selectedPage}" data-href1="{$Link}" data-href="{$Link}" title="" class="readmore_btn small" href="{$Link}" >
    

    The Output in RTE backend is

    <a data-id="1136" href="/home/?id=1" title="" class="readmore_btn small" data-href1="/{localLink:1136}?id=1" data-href="http://localhost:50383/home/?id=1"> order </a>
    

    you can see href and data-href are transformed by xslt, i dont want it to be transformed

    I want href="/{localLink:1136}?id=1

    Let me know any other way to achieve this

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Jan 31, 2017 @ 08:30
    Chriztian Steinmeier
    0

    Hi Vishmay,

    If I remember correctly, I don't think it's possible — Umbraco does this replacement "behind your back", so to speak.

    Have you checked the final frontpage output? I seem to remember spending time trying to "fix" this at some point, only to find out that it actually did work as expected in the final result.

    The only way to test it is to add the macro to a page, publish the page and then check the Umbraco.config file on disk and see if the links have been changed/transformed.

    Hope that helps,

    /Chriztian

  • Vishmay 19 posts 100 karma points
    Jan 31, 2017 @ 08:45
    Vishmay
    0

    In Backend RTE if you add link with insert/edit link, it will create such url. The advantage of it is, renaming or moving to sub/parent a page, the link does not need to relocate.

    I want some customization in link so i created macro

    Front end will have static url by current method, it will work fine until you rename/move page.

    create macro by given snippet. and in a page in RTE Select one link with insert link and other link by our macro. I want both of them have same output. nothing else.

        <?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:Examine="urn:Examine" 
        exclude-result-prefixes="msxml umbraco.library Examine ">
    
    
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    
    <xsl:param name="currentPage"/>
    <xsl:param name="selectedPage" select="/macro/selectedPage"/>
    <xsl:param name="QueryString" select="/macro/QueryString"/>
        <xsl:variable name="Link" select="concat('/{localLink:' , $selectedPage , '}' , '?' ,$QueryString)"/>
    <xsl:template match="/">
    
    <!-- start writing XSLT -->
    <a data-id="{$selectedPage}" data-href1="{$Link}" data-href="{$Link}" title="" class="readmore_btn small" href="{$Link}" >
        Order
        </a>
    </xsl:template>
    
    </xsl:stylesheet>
    

    you can check data-href1 is assigned with same variable but produces different result(Expected).

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Jan 31, 2017 @ 08:54
    Chriztian Steinmeier
    0

    Hi Vishmay,

    I assume you've confirmed that the URLs have been replaced in the Umbraco.config then...

    Another thing you could try, is to disable rendering the macro in the RTE (so you can insert it but it won't be rendered until the page is previewed or rendered for the frontend). It may not work but then again, it could work :)

    Probablyn ot an ideal editor-experience, though...

    /Chriztian

  • Vishmay 19 posts 100 karma points
    Jan 31, 2017 @ 09:56
    Vishmay
    0

    Output from umbraco.config

     <a data-id=\"1136\" href=\"/home/?id=ppt\" title=\"\" class=\"readmore_btn small\" data-href1=\"/{localLink:1136}?id=ppt\" data-href=\"http://localhost:50383/home/?id=ppt\"> Order </a>
    

    How to disable rendering the macro in the RTE?

  • Vishmay 19 posts 100 karma points
    Jan 31, 2017 @ 10:45
    Vishmay
    0

    Can I get you to look at a request as you are admin(please check links below)

    if umbraco can provide facility to add custom key value pairs while adding link from RTE insert link's treeview and then append as data in anchor tags like

    Name: HashLink

    Value : Section1

    We can then change it in front end by javascript

    reference

    https://our.umbraco.org/forum/extending-umbraco-and-using-the-api//83646-hash-tag-links-in-insert-link-in-umbraco-internal-link

    https://our.umbraco.org/forum/using-umbraco-and-getting-started/83611-umbraco-link-editor-in-rte-select-other-page-from-menu-and-add-querystring

Please Sign in or register to post replies

Write your reply to:

Draft