We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33997
    • 150 Posts
    I am trying to make my new site as accessible as possible, and want to add a text resize button. I don’t want to do it via JS, because then people without js can’t use the feature, so I found an article on alistapart.com that discusses how to do this with cookies and php. The problem is, when I tried to make my own snippet, it wouldn’t work. I don’t know how and where to implement it. The code is already written, it just needs to be reworked slightly to work with MODx.

    The article from A List Apart is here: http://www.alistapart.com/articles/phpswitch/

    All it does is use a cookie to select a stylesheet based on user preferences. Please help!!
      "Great spirits have always encountered violent opposition from mediocre minds." -Albert Einstein
      • 3749
      • 24,544 Posts
      That article is from 2002. I think all users who need larger text now have browsers with the ability to change text size and most people who are paranoid enough to have javascript off will have cookies off too.

      That said, it’s not trivial to do in MODx. Because of how MODx handles PHP code, a simple snippet won’t do it. For "Stage One" of the article, you’d want a form to select the styles. The action of that form would be to post the selection to a separate document that contained just the snippet call to the snippet with PHP code in it that would use the $_POST variables to set the cookie.

      Then, for stage two, you’d need to create another snippet (call it GetStyle) that would read the cookie and echo the name of the appropriate CSS file.

      Finally, in your template, you’d have something like this:


      <link rel="stylesheet" type="text/css" 
      	media="screen" title="User 
      Defined Style" href="[!GetStyle!].css" />


      I’m still not sure it would work. You’d have to try it.

        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 33997
        • 150 Posts
        That bad, huh? Yeah, I know most people’s browsers have that ability, but also a lot of people don’t know how to do it. Maybe I’ll just put a link saying ’larger text’ and if they click it, it’ll take them to a page (or even use a floating box with a hover tooltip or something) that explains how to do it in different browsers. Think that’d work? or should i just say forget about the people that don’t know about resizing text lol? (or have you seen a js for this that works well? the ’textresize’ in the snippets in the resources was kinda buggy - i’d click smaller and everything would become tiny, and then larger would not keep a uniform look across teh page.....)

        the whoas of accessibility, huh?
          "Great spirits have always encountered violent opposition from mediocre minds." -Albert Einstein
          • 3749
          • 24,544 Posts
          There’s a MODx site listed in the "you and your sites" forum that has buttons to make the text bigger and smaller. It’s JS and it works really well but I don’t know the URL.

          Here’s another take on the issue: http://www.456bereastreet.com/archive/200709/scrap_text_resize_widgets_and_teach_people_how_to_resize_text/
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 33997
            • 150 Posts
            He’s got a point. Thanks for all your help, btw, I’ve spent a decent amount of time learning MODx from your posts on your site, and they have helped me considerably, so thanks again.
              "Great spirits have always encountered violent opposition from mediocre minds." -Albert Einstein
              • 25483
              • 741 Posts
              I used a style switcher to change the font size on http://www.avides.nl

              In the top-right you see 3 times "a", there you can choose which site you want. It’s just some JS and CSS files smiley
                with regards,

                Ronald Lokers
                'Front-end developer' @ h2o Media