Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Font Size Increase Decrease Webpart View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
Gitesh - 5/24/2012 1:20:24 AM
   
Font Size Increase Decrease Webpart
HI Guys,

Is there a feature to increase and decrease font Sizes in kentico from frontend by a website user. I have seen this feature in many websites but never found in kentico.

I have looked for different webpart options but can't find one.

Your help is appreciated.

Thanks
Gitesh shah

User avatar
Kentico Support
Kentico Support
kentico_janh - 5/24/2012 2:15:53 AM
   
RE:Font Size Increase Decrease Webpart
Hello,

There is a web part called CSS style selector, which can be used for this exact functionality. For more information, please click here. To see how this web part works please install sample Corporate Site and on this site's masterpage is your requested font size selector.

Best regards,
Jan Hermann

User avatar
Certified Developer v7
Certified  Developer v7
Gitesh - 5/24/2012 3:26:42 AM
   
RE:Font Size Increase Decrease Webpart
Hi Jan,

Thanks, that's exactly what I am looking for.

But it doesn't work when javascript is disabled. we are looking for a common solution which works cross browser and even when javascript is disabled.

Any ideas how to make it work when javascript is disabled?

Thanks
Gitesh Shah

User avatar
Kentico Support
Kentico Support
kentico_janh - 5/24/2012 3:47:38 AM
   
RE:Font Size Increase Decrease Webpart
Hello,

I have an idea to create a custom web part, which would store a cookie according to the query string (links with a query string for the font resizing) and this web part would only set another body class (regarding the current cookie) for which you have defined different font sizes:

protected override void OnInit(EventArgs e)
{
CMS.CMSHelper.CMSContext.CurrentBodyClass += " smallFontSize";
}


Best regards,
Jan Hermann

User avatar
Certified Developer v7
Certified  Developer v7
Gitesh - 6/13/2012 8:13:04 PM
   
RE:Font Size Increase Decrease Webpart
Hi Jan,

This webpart works great.

But now I have one more issue. My website changes domain names in different pages of the site. As this webpart is storing a cookie based on the domain name, it looses the cookie when I go on any other page of the site with a different domain name.

Can we store a cookie with this webpart without storing the domain details?
or Can we store a cookie with this webpart for any domain name that uses that cookie name?

Thanks
Gitesh Shah

User avatar
Kentico Support
Kentico Support
kentico_janh - 6/14/2012 2:24:25 AM
   
RE:Font Size Increase Decrease Webpart
Hello,

Regrettably, the internet browser stores cookies according to the domain, so you can't force storing cookie for a different domain, but you can store an information about the font size into the session instead of a cookie and the session is available till you close your browser.

Best regards,
Jan Hermann

User avatar
Certified Developer v7
Certified  Developer v7
Gitesh - 6/20/2012 5:52:14 PM
   
RE:Font Size Increase Decrease Webpart
Hi Jan,

Can the webpart do with sessions or will I need to alter the webpart?

Thanks
Gitesh Shah

User avatar
Kentico Support
Kentico Support
kentico_janh - 6/23/2012 3:37:22 AM
   
RE:Font Size Increase Decrease Webpart
Hello,

You can check in that OnInit method if the query string with font size definition is present in the url, set the session variable according to it by using CMS.GlobalHelper.SessionHelper.SetValue(String, String) and set also the body class as I posted before. This body class is always set regarding to the value in the session (CMS.GlobalHelper.SessionHelper.GetValue(String)). Is it clear or do you need that entire code example?

Best regards,
Jan Hermann

User avatar
Certified Developer v7
Certified  Developer v7
Gitesh - 11/11/2012 7:26:20 PM
   
RE:Font Size Increase Decrease Webpart
Hi Jan,

I have started to make this webpart to work with sessions instead of cookies.

Below are the changes that I have made:
Original line:

string cookieValue = ValidationHelper.GetString(CookieHelper.GetValue(CookieName), "");

Changed it to:

string cookieValue = ValidationHelper.GetString(SessionHelper.GetValue(CookieName), "");



Original Line:

CookieHelper.SetValue(CookieName, e.CommandArgument.ToString(), DateTime.Now.AddYears(50));


Changed it to:

SessionHelper.SetValue(CookieName, e.CommandArgument.ToString());


You can find the full code on the below link:
http://demo.kudosweb.com/files/code.txt

Webpart has started to work with sessions now. But when I change the domain name it still cannot understand the value. For some reason, it is still behaving just like the cookie webpart.

Any ideas what am I doing wrong?

Thanks
Gitesh Shah

User avatar
Kentico Support
Kentico Support
kentico_janh - 11/16/2012 5:10:03 AM
   
RE:Font Size Increase Decrease Webpart
Hello,

The problem is that the session key is stored in the cookie by default, so this is a domain specific variable as well. However if those two domains are on one server and use the same session store, you can use the Cookieless ASP.NET Session config to access those variables from a different domain, but just in this case. For more information please follow the link below:

http://stackoverflow.com/questions/11474789/share-session-state-across-multiple-domains-in-net-not-sub-domains

Otherwise, you would need to store the value of a font size to the database for that user and select it on that different domain to make it work.

Best regards,
Jan Hermann