URL ecoding via render tag.

122 views
Skip to first unread message

Dmitry Terner

unread,
Jul 18, 2011, 11:09:54 AM7/18/11
to reddot-c...@googlegroups.com
Is URL ecoding via render tag at all possible? Or if not, what strategies have you used especially if there are single or double quotes and ampersands in the field and you need to pass the value via querystring.
 
Thanks,
 
- Dmitry
 

Jian Huang

unread,
Jul 18, 2011, 6:11:03 PM7/18/11
to RedDot CMS Users
Hi Dmistry,

Can you elaborate on the issue?

If the URL is coming from an anchor, you can

<!!%
HtmlEncode(Context:CurrentPage.Element.GetPage(anc_link).Value[Int32:0].GetUrl()) !!
%>

Please note, I have not tested the aforementioned rendertag, just
writing it from memory.

Would javascript be a suitable choose for manipulating links
parameters?

Best,

-Jian

Dmitry Terner

unread,
Jul 20, 2011, 11:36:55 AM7/20/11
to reddot-c...@googlegroups.com
Hi Jian,

My use case is this:

let's say that In CMS my content class has this

<a href="<%anc_Main%>"?<%hdl_Headline%>">Link</a>

but headline can be anything so it may publish this:

http://mysite.com/page.htm?title=This & that

Obviously I need to encode "this & that" so it becomes "this%20%26%20that" or the link won't work

I don't really want to do this via javascript on the client side so I was wondering if there was a way to publish the page with correct encoding using render tags.

Thanks,

- Dmitry




Jian Huang

unread,
Jul 21, 2011, 10:52:14 AM7/21/11
to RedDot CMS Users
Hi Dmitry,

Yes, it is possible to do it with Rendertag

<%!! Escape:Text(<%hdl_Headline%>).Replace(&,%26).Replace(Escape:Space,
%20) !!%>

Best,

-Jian

On Jul 20, 11:36 am, Dmitry Terner <dmi...@terner.ws> wrote:
> Hi Jian,
>
> My use case is this:
>
> let's say that In CMS my content class has this
>
> <a href="<%anc_Main%>"?<%hdl_Headline%>">Link</a>
>
> but headline can be anything so it may publish this:
>
> http://mysite.com/page.htm?title=This& that

Dmitry Terner

unread,
Jul 21, 2011, 2:30:50 PM7/21/11
to reddot-c...@googlegroups.com
so I would need to chain a Replace for every special character?

Jian Huang

unread,
Jul 22, 2011, 8:55:21 AM7/22/11
to RedDot CMS Users
Hi Dmistry,

If using Rendertag in version 10 or less, YES, chaining is the way to
go.

In version 11, custom rendertag is available.

Just like any other system, server side execution is neccessary if one
wants to manipulate data prior to client side response.

Also, preexecution is another alternative.

Best of luck. Please post back with your final solution either here
or on http://www.solutionexchange.info/

-Jian
Reply all
Reply to author
Forward
0 new messages