Jump to:

23007 Posts in 11866 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » ability for user to set font size

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1559 Views
  • dreamstudio
    Avatar
    Community Member
    48 Posts

    ability for user to set font size Link to this post

    We need to add a function on the site where the user can click on a button to change the size of the font, from small to large. We know that on the browsers you can set this but the users in question wont be very knowledgable and we require the facility on the page so they can easily and quickly change the font sizes

    We have seen it on many sites and have seen some code to do it, however does anyone have any idea on the best way of doing it via SS....based on the font size in the css and changing it? is there almost a way to change template files or reload a css file? or simply change the font size in question to different size

  • Howard
    Avatar
    Community Member
    215 Posts

    Re: ability for user to set font size Link to this post

    This is really easy - I just used this exact method http://labnol.blogspot.com/2006/12/allow-site-visitors-to-change-font.html on a ss site and it worked right out of the box.

    The JS adds inline font-size styles to any p element and the links activate the change in the inline styles. You would want to set the initial value in the JS to your default font-size, it is currently set to 12 by default.

  • dreamstudio
    Avatar
    Community Member
    48 Posts

    Re: ability for user to set font size Link to this post

    That was easier than I thought it would be, the only question is, if I wanted every page to then keep the same font size, how do i do that as it reloads and the font returns to normal size so they would need to resize it again on each page

  • Howard
    Avatar
    Community Member
    215 Posts

    Re: ability for user to set font size Link to this post

    Yea not to hard to do but you will have to get into a little bit of code - use javascript to store a cookie containing the set variable then access that cookie on each page load. I normally use jQuery for most of my javascript stuff cause it is cooler - there is quite a good walkthrough on using cookies with jquery here http://www.shopdev.co.uk/blog/cookies-with-jquery-designing-collapsible-layouts/ You will need to adapt it to apply the inline styles on pageload as well. Hope this is a point in the right direction

    1559 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.