We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14509
    • 14 Posts
    After reading the following post
    http://modxcms.com/forums/index.php?topic=11992.0

    I was wondering if there are any ’updated’ ways to have font size buttons on a site.

    The main reason why i ask is because i rather like the URL clean instead of having it showing the font-size variable.
    Can it all be done through cookie so the URL stays clean?

    Thank you in advance
      • 33372
      • 1,611 Posts
      The code in the post that you link to actually does set a cookie and uses that value once it’s been submitted. So once a user clicks on one of the font size links, subsequent pages will respect their choice wihout adding anything to the URL query string. You have to pass their choice to the script somehow, and a $_GET variable seems like a good way to do that to me. But if you really don’t like any of those ever, you could use a form with the POST method instead, or I suppose that you could have separate pages that you link to for each font choice which would set the cookie and then redirect back to the original page. You could also use mod_rewrite to make the query string "friendly" (e.g., yoursite.com/yourpage/bigger/).
        "Things are not what they appear to be; nor are they otherwise." - Buddha

        "Well, gee, Buddha - that wasn't very helpful..." - ZAP

        Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
        • 5689
        • 289 Posts
        Edit: I didn’t realize ZAP posted while I was typing. Here’s my post anyway. smiley

        I’m thinking that you could set up an HTML form for each button using POST. Then you’d create a document and a snippet with some PHP to process the form and set the cookie accordingly. I’m not sure if you could pull of a way to just use one form or not, but either way, you should still only need one processing page. And actually, if you want, you don’t even need to use a document for the form processor. You could just create a PHP file with the code and call that and have it redirect to a MODx page.

        Here’s an example of the forms I would create.
        <form action="formProcessor.php?size=1" method="post">
        <p><input type="button" name="submit" value="Small Font"></input></p> <!-- the p tags are for XHTML Strict (Transitional also?) -->
        </form>
        <form action="formProcessor.php?size=2" method="post">
        <p><input type="button" name="submit" value="Medium Font"></input></p> <!-- the p tags are for XHTML Strict (Transitional also?) -->
        </form>
        <form action="formProcessor.php?size=3" method="post">
        <p><input type="button" name="submit" value="Large Font"></input></p> <!-- the p tags are for XHTML Strict (Transitional also?) -->
        </form>
        


        The PHP code you’d use would be very similar to the code in that other topic.

        By the way, though, with the other topic’s method, the user would never even see the query string on the URL, so it’d still be clean. The button would link to page that sets the cookie, and if that page redirected to a MODx page without a query string, you’d never even see it. Just throwing that out there. laugh
          I&#39;m learning more about MODx all the time and loving it.
          • 14509
          • 14 Posts
          Thanks guys, i’ll give it a try smiley
            • 26931
            • 2,314 Posts
            Hi there,

            using that method, (how) would it be possible to change the size with two buttons? e.g.
            font size: [+] [-]


            thanks, j