Categories > TinyButStrong general >

Simplifying var..cst field

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: martijn
Date: 2007-05-20
Time: 19:13

Simplifying var..cst field

I've just started over with my CMS to make it multi-theme compatible, and thought it would be nice to make a small wrapper for the [var..cst.CONSTANT]-field.
However, I don't have a clue how to do this, I mainly want to simplify:
[onload;file=[var..cst.THEMES_DIR]default/head.html]
to
[skinfile=head.html]
(the directory "default" will be replaced by a variable later on).
Is this possible to do? Thanks in advance!
By: Skrol29
Date: 2007-05-21
Time: 00:05

Re: Simplifying var..cst field

Hi,

You can have easilly
[skin;file=head.html]
You can do it with the $TBS->MergeField() method to use with method and a custom function.
You can have it all automatic if you code a plug-in which does the same.
By: martijn
Date: 2007-05-23
Time: 07:13

Re: Simplifying var..cst field

Hi,
I don't get exactly what you mean with: "You can do it with the $TBS->MergeField() method to use with method and a custom function.".
By: martijn
Date: 2007-05-23
Time: 07:15

Re: Simplifying var..cst field

I forgot to post what I currently have in my plugin file (not much):
<?php
    define('TBS_GLOBAL_FUNCTIONS', 'Plugin_Functions');
    class Plugin_Functions{
        function OnInstall(){
            $this->Version = '0.01';
            return array('BeforeLoadTemplate', 'AfterLoadTemplate');
        }
        function BeforeLoadTemplate(&$File,&$HtmlCharSet){
            $File = THEMES_DIR.THEME."/".$File;
        }
       
        function AfterLoadTemplate(&$File,&$HtmlCharSet){
            return false;
        }
    }
?>
By: Skrol29
Date: 2007-05-23
Time: 17:09

Re: Simplifying var..cst field

Hi,

I suggest this (not tested):
It merges fields like this [onload;ope=skin;file=header.html]

<?php
define('TBS_GLOBAL_FUNCTIONS', 'Plugin_Functions');

class Plugin_Functions{

  function OnInstall(){
   $this->Version = '0.01';
   return array('BeforeLoadTemplate','OnOperation');
  }

  function BeforeLoadTemplate(&$File,&$HtmlCharSet){
   $File = THEMES_DIR.THEME."/".$File;
  }
  function OnOperation($FieldName,&$Value,&$PrmLst,&$Txt,$PosBeg,$PosEnd,&$Loc) {
   if ($PrmLst['ope']=='skin') {
    if (isset($PrmLst['file'])) $PrmLst['file'] = THEMES_DIR.THEME."/".$PrmLst['file'];
   }
  }

}
?>

You can complete this to do the same with "script=".