• How to delete an MPTT Node

    By Andy, filed under CakePHP, Tools, ACL, Tips, MPTT, Hacks, SQL

    If you use MPTT tables anywhere (The cake acl system uses it) you may have found that when you delete an entry, the lft and rght fields for the neighouring nodes don't get updated. This may have rather dire concequences ;)

    There is an open ticket for how to delete from the cake acl tables, but as it is potentially quite generic, I thought I'd include the (potential)...

    read more1 comment

  • Elements and Recursion

    By Andy, filed under CakePHP, Tips, requestAction

    A long time ago, I took to using elements as shown in the paste below.

    echo $this->renderElement("Element",$params);
    
    1. echo $this->renderElement("Element",$params);
    2.  

    At the time, this was the only way I could find to pass the information from the view in general to the element. If this was needed at all, it was probably a temporary glitch but I kept to this syntax since that time. It is overkill to do this now, and...

    read more0 comments

  • Where did I put that call?

    By Andy, filed under CakePHP, Tips, Hacks

    In the site update, this little tidbit went missing, so here it is again:

    function pr($var) {
        if (DEBUG > 0) {
            
    
    $array = debug_backtrace();
            echo(str_replace(ROOT, "", $array[0]['file'])." (line ".$array[0]['line'].")");
       
    
         echo "<pre>";
            print_r($var);
            echo "</pre>";
        }
    }
    
    1. function pr($var) {
    2. if (DEBUG > 0) {
    3. $array = debug_backtrace();
    4. echo(str_replace(ROOT, "", $array[0]['file'])." (line ".$array[0]['line'].")");
    5. echo "<pre>";
    6. print_r($var);
    7. echo "</pre>";
    8. }
    9. }
    10.  

    With this minor change, you can see where your debug calls are...

    read more0 comments

  • Site Update

    By Andy, filed under General, NoswaD

    Well I hit a few problems when I moved the site contents to

    the live server, there's always something that catches me out developing on (case-insensetive file system) Windblows and

    deploying to (case-sensetive file system) linux. But hey, now the site is back ;)

    read more2 comments

  • The last Paginate

    By Andy, filed under CakePHP, Tools, Pagination

    Over the past couple of days, I finally got around to putting a few updates in place to the pagination code I wrote a while ago. Especially in light of Nate's recent post I think I'll call it a day at that ;)

    I've updated the Pagination package to be tidier and easier to edit, and adding the possibility to paginate ajax form results as well as including simple select...

    read more1 comment

  • Sessions and Plugins

    By Andy, filed under CakePHP, Tips, Sessions, Plugins

    If you use plugins, you may have noticed that your app session data isn't avaialbe in your plugins and vice-versa. There's a good reason for that, as a plugin is intended to be a mini application, self contained etc.

    In my case, this was a problem as my plugins are extensions or parts of my application and not seperate. To get around the wandering session data it was...

    read more6 comments

  • International Number formats

    By Andy, filed under CakePHP, Tips

    Perhaps this will be useful for others.

    I needed to be able to convert decimal number to and from the 'local' format. By adding the below methods to my app_model, it is possible to silently convert decimal numbers as they come out of the database to be local format, and vice versa to save. In the code below it is converting numbers of the format 999.999,99 to be...

    read more2 comments

  • Even More Pagination

    By Andy, filed under CakePHP, Tools, Pagination

    I've enhanced the pagination code and added more improments. Mainly in terms of use, as it is now virtually identical to use as either get, pretty, or named style.

    This one is probably the most interesting example:

    Noisy Named Params

    The source code is (for all examples) is available at the top of the page.

    Time for sushi :)

    read more3 comments

 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8