Categories


Archives


Recent Posts


Categories


“Smart Quotes”

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

I finally got around to integrating the excelent “SmartyPants” plug-in with this website. Since I use a PHP CMS I hacked together myself, i wrote a little wrapper class for the perl script. If you’re into that kind of thing, the code for said wrapper is below. I’ve only tested this in PHP 4, but if you’re using PHP 5 you can probably figure out what’s wrong.

Use freely and at your own risk, this code is provided “as is” and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed.

   //create a new instance of the class

    $sp = new smarty_pants_wrapper('/path/to/SmartyPants.pl');

    

    //educate your quotes 

    $educated_string = $sp->doit($string);

    

    //pass additional arguments to the plugin

    $educated_string = $sp->doit($string,'-2');     

    

    class smarty_pants_wrapper{

        var $pants_path;

        function smarty_pants_wrapper($path){

            if(!file_exists($path)){

                die("Could not find smarty pants plugin at $path");

            }

            else{

                $this->pants_path = $path;          

            }               

        }

        

        function doit ($input, $args='') {

            $input = escapeshellarg($input);

            return shell_exec("echo $input | $this->pants_path $args");

        }

        

    }

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 15th May 2005

email hidden; JavaScript is required