auto-registering templates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ratorasniki
    Member
    • Oct 2000
    • 83

    auto-registering templates

    posted this in code hacks about a week back, but i figured y'all might like it as well:

    to make your template.php create instantly useable templates from the form (instead of having to go into global.php and register them) open /admin/template.php and find

    Code:
      $DB_site->query("INSERT INTO template (templateid,title,template) VALUES (NULL,'".addslashes("$title")."','".addslashes("$template")."')");
    under it add

    Code:
    # added template code
    # echo "title is $title <br>"; # debugging
    $filename = "rattemp.php";
    $str = '<?php eval("\$'; 
    $str .= $title; 
    $str .= ' = \"".gettemplate("';
    $str .= $title;
    $str .= '")."\";"); ?>';
    $fp=fopen($filename, 'a+'); 
    fwrite($fp,"$str \n"); 
    fclose($fp);
    
    # end
    then open up global.php and find
    Code:
    eval("\$fivelinks = \"".gettemplate("fivelinks")."\";");
    and under it add
    Code:
    require ("admin/rattemp.php");
    now create an empty file called /admin/rattemp.php and upload it, make sure its CHMOD-ed to 666, and you're set. also note if you delete custom templates, this wont remove the reference from the rattemp.php file, you'll have to do that manually, but i did this for my design guy who isnt really one to go trekking through code when he wants to make a template
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...