Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Cookie Value on Anchor Links View modes: 
User avatar
Member
Member
jackdavis1857-gmail - 6/3/2013 11:07:29 PM
   
Cookie Value on Anchor Links
Hi,

I have code written inside the master file, that captures a query string parameter value from URL and stores it inside a cookie.

I want this value of the cookie to be used on anchor links or other links on the site.

When i try to include code like this:
<a href="/something/somethingelse/<%= Response.Cookies("cookie-name")%>"

inside a widget (Static HTML/Rich Text Widget), the <%=%> is rendering into html codes rather than code blocks.

(1) How can i use such custom code blocks through the widget to access the Cookie value??

(2) Or is there a way to store the cookie inside a Macro, and use the Macro on those anchor links??? if Yes, where do i set the value of the cookie from the URL parameter to the Custom Macro?? Can you give an example??

Thank you

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 6/4/2013 8:18:41 AM
   
RE:Cookie Value on Anchor Links
Take a look at the types of macros available. I believe the {%Cookies[" "]%} is what you're looking for with a cookie.

User avatar
Member
Member
jackdavis1857-gmail - 6/4/2013 9:26:00 AM
   
RE:Cookie Value on Anchor Links

Yes, Thank you.

But it doesn't say where and how i can set the value of the cookie.!!!

Can i use the same cookie name i used in the master.cs file like:
Response.Cookies["cookieName"]="test";

and use it as the macro like {%Cookies["cookieName"]%} on the page???

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 6/4/2013 9:29:38 AM
   
RE:Cookie Value on Anchor Links
jackdavis1857-gmail wrote:
Can i use the same cookie name i used in the master.cs file like:
Response.Cookies["cookieName"]="test";
Yes.
jackdavis1857-gmail wrote:
and use it as the macro like {%Cookies["cookieName"]%} on the page???

Yes.

User avatar
Member
Member
jackdavis1857-gmail - 6/4/2013 12:12:42 PM
   
RE:Cookie Value on Anchor Links
thanks.

I tried to use the same cookie i created in the master.cs file in the macro, but the Rich Text editor is simply rendering it as plain text instead of the actual value.

when i hav the url value /something/Somethingelse?cookieName=2013

its displayin as : cookie value : {%Cookies[" cookieName "]%}

instead of : cookie value : 2013

From the WYSIWYG editor on clickng insert micro should i follow anything else?? the insert macro method is inserting the macro as {% cookieName %}, but this also gets rendered as plain text.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 6/4/2013 12:54:29 PM
   
RE:Cookie Value on Anchor Links
Remove the spaces before and after the "@". Found this with the querystring macro as well. Should follow the exact description as shown in the manual.

Should look like this:
{%Cookies["cookieName"]%}

NOT like this:
{%Cookies[" cookieName "]%}

User avatar
Member
Member
jackdavis1857-gmail - 6/4/2013 1:10:39 PM
   
RE:Cookie Value on Anchor Links
Nope. Didn't work.

Still rendering as plain text.

User avatar
Member
Member
jackdavis1857-gmail - 6/4/2013 1:27:55 PM
   
RE:Cookie Value on Anchor Links
Ok. It works if i place the {%Cookies["cookieName"]%} outside the widget.

But if i drop the same {%Cookies["cookieName"]%} inside a widget, example: Rich Text Widget, it is getting rendered as plain text, instead of the value.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 6/4/2013 1:50:28 PM
   
RE:Cookie Value on Anchor Links
Don't copy and paste the macro and don't just type it in, use the Insert Macro feature if you haven't already. I'm able to get it to work without a problem.

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 6/4/2013 10:50:32 PM
   
RE:Cookie Value on Anchor Links
Hi,

As far as I can tell and seen before the macro's are not resolved inside widget due to some security reasons. So inside all widgets the macro should not get resolved.

What you can do is to use web part such as Editable text instead and use the macro there.

Can you try to resolve macro there? Does it work?

Kind regards,

Richard Sustek

User avatar
Member
Member
jackdavis1857-gmail - 6/5/2013 4:29:45 PM
   
RE:Cookie Value on Anchor Links
Thanks Richard.

It works inside the editable text, however my requirement is to have it work inside a widget. however, looks like its not working.

Unfortunate..!!