User Login    
 + Register
  • Main navigation
Login
Username:

Password:


Lost Password?

Register now!
Documentation
Who's Online
125 user(s) are online (10 user(s) are browsing XoopsWiki)

Members: 3
Guests: 122

julius-leo, trabis, bravo, more...
[Main Page]

Dev:Templates from Filesystem

From XOOPS Project

Main Page | Recent changes | Edit this page | Page history | Switch to MediaWiki mode

Printable version | Disclaimers | Privacy policy
Category: Development

I'm writing this here because if think it's a bit long for a "comment".

Here's the way I managed to hack to kernel so my templates can be fetched from the filesystem instead of the db. It's a bit tricky and should only be used for dev purposes but it worked for me, and I think being able to edit template files using your fav editor is much faster than having to go through the admin interface each time you want to change one line.

1) Change Xoops 'footer.php' file (within site root dir) using the code I put at the end of this comment. 2) Create a 'templates' folder inside your current theme folder, and copy your tpl files there 3) Remove the 'db:' prefix from the template name in you module pages

   $xoopsOption['template_main'] = 'pskrecord_pg_index.tpl';

4) If your template includes other ones, ensure you don't use the 'db:' prefix, but do it like this:

   <{include file="$xoops_theme/templates/pskrecord_vw_labels.tpl"}>

Now the tpl files will be fetched from the 'templates' dir. Once you've finished working on them, you just have to do a global replace on all you files changing "$xoops_theme/templates/" to "db:"

Told you it was tricky... Maybe there's a better way, but it didn't manage to find it (already had to scratch my head a lot for this one). I believe it can be enhanced by hacking another part so we don't have to use the "$xoops_theme" string for includes, but I stopped at this point, at it was enough for my needs.

There's an option in xoops prefs that tells it just does that, but I never managed to make it work...

Hope it can help some of you...


Here's the code to change in footer.php (aroud line 50):

    // RMV-NOTIFY
    include_once XOOPS_ROOT_PATH . '/include/notification_select.php';
    if (isset($xoopsOption['template_main'])) {
    if (isset($xoopsCachedTemplateId)) {
    $xoopsTpl->assign('xoops_contents',
    $xoopsTpl->fetch('db:'.$xoopsOption['template_main'],
    $xoopsCachedTemplateId));
    } else {
    // Skalpa-hack: Allow template fetching from filesystem
    if
    (file_exists(XOOPS_ROOT_PATH.'/themes/'.$xoopsConfig['theme_set'].'/templates/'.$xoopsOption['template_main']))
    $tpl_prefix=$xoopsConfig['theme_set'].'/templates/';
    else
    $tpl_prefix='db:';
    $xoopsTpl->assign('xoops_contents', $xoopsTpl->fetch($tpl_prefix .
    $xoopsOption['template_main']));
    }

Back to the dev:Main Page

Retrieved from "http://www.xoops.org/modules/mediawiki/index.php/Dev:Templates_from_Filesystem"

This page has been accessed 373 times. This page was last modified 01:41, 16 December 2007. Content is available under XOOPS Project.


Local Support Sites
Powered by
XOOPS Code hosted on SourceForge

Powered by PHP



Powered by MySQL

Powered by Smarty

OSI certified

All content on this site is subject to the Creative Commons License
Developers for Hire