tips for debugging templates  Bottom


  • I know some of you already know this, but i think it can't be usefull for newbies, who doesn't know which variables to display in template.

    So, if you want to display all available variable, you can use in a template,

    Code

    <!--[pndebug]-->


    just copy past this in your template

    this will add a popup with all template variables.

    http://luffyserveur.free.fr/smarty.PNG

  • Some variables are not display in the pnDebug (for instance when you call a plugin which return a variable by a assign)

    If you wan't to display this variable, you have to use the print_r on the "array" level (use an @ for the modifier)

    for instance

    Code

    <!--[pnmodapifunc modname='pagemaster' checkPerm=true handlePluginFields=true getApprovalState=true func='getPub' tid='2' pid=$theme assign='theme_publication']-->
    <pre>
    <!--[$theme_publication|@print_r]-->
    </pre>




    edited by: mumuri, Jan 04, 2009 - 12:47 AM
  • The print_r tip is great. Didn't know that one icon_wink

    --
    campertoday.nl, Module development, Dutch Zikula Community
  • useful! even for non newbies.. thanks

    --
    Cytopia - Download Psytrance




    Athens Pub Crawl
  • and the last one ... print_r for javascript object

    Code

    function print_r(theObj){
     if(theObj.constructor == Array ||
     theObj.constructor == Object){
     document.write("<ul>")
     for(var p in theObj){
     if(theObj[p].constructor == Array||
     theObj[p].constructor == Object){
    document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
     document.write("<ul>")
     print_r(theObj[p]);
     document.write("</ul>")
     } else {
    document.write("<li>["+p+"] => "+theObj[p]+"</li>");
     }
     }
     document.write("</ul>")
     }
    }


    http://www.brandnewbox.co.uk/logbook/article/a_print_r_equivalent_for_javascript/



    edited by: mumuri, Jan 11, 2009 - 07:45 AM
  • Excellent one!
    I've needed it many times, so debugged the "suspect" values only icon_razz
    Thanks a lot!

    --
    - Mateo T. -
    Mis principios... son mis fines
  • @ is only needed of you want to apply a PHP command as modifier on all elements of an array - you don't need it for strings and so on.

    --
    best regards from Kiel, sailing city

    Steffen Voss

    Member of the Zikula Steering Committee
    Read The Zikulan's Blog "If you want people to RTFM, make a better FM!"
  • yes, that was the case, usually you don't do a print_r to display a string.
  • this 'tool' seems to break my site sometimes. I know its only for temporary, debugging useage but it shouldn't break menus should it? Specifically, it is messing up my if/elseifs for which menu to use based on if a user is logged in..

    --
    [ stevencopley.com ]

This list is based on users active over the last 60 minutes.