Categories > TinyButStrong general >

Using TBS with Mambo.

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Gerome
Date: 2006-12-10
Time: 23:47

Using TBS with Mambo.

Hello !

I've to say that TBS is really great. I've been using it for few php project in the past few weeks and I am impressed by how small become the PHP code when using TBS.

I am currently using Mambo and I noticed that Mambo make the use of really unfriendly template with a strange mix of PHP and html. I decided then to use TBS with mambo.

The problem I have is thgat Mambo call function from its templates. These function contains "echo" functions in it. It means that I can't save the result of these functions into variable.

Is that possible to dirrectly call a function from TBS ?
something like...
[fnc.function_name]
If not I guess it shouldn't be too hard for me to had it to the template.

I will let it know when the TBS for Mambo will be working...

Thank you for your help,

Gerome.
By: Scythe
Date: 2006-12-11
Time: 00:00

Re: Using TBS with Mambo.

I've designed sites in Mambo prior.   The Mambo engine is very unique in how it passes variables to the templates.  It's very possible to use TBS with Mambo, but it'll be difficult to make it work (due to their variable handling).  Also, using 2 templating systems together will cause excess code execution and processing time. 
By: Gerome
Date: 2006-12-11
Time: 00:24

Re: Using TBS with Mambo.

That's not wrong.

I don't know how much it would slow down the website. I think I will give it a try and see how it goes...

I just found the function onformat=fct_name that should resolve my problem of executing a function from the template.

The question is: is the "echo" calls working from this function ?
By: Skrol29
Date: 2006-12-11
Time: 01:08

Re: Using TBS with Mambo.

Hi,

If a TBS template could run any PHP function it would be a security problem.
TBS accepts to run functions defined in parameters "onformat" and "ondata" only. And sunch functions must have a certain declaration.

Nevertheless, you can have some customized tags to run your PHP functions from the template. The first way to do this is to place some tags like [fnc.function_name] in the template. Then in PHP do :
$TBS->MergeField('fnc','f_merge_ft',true);
...
function f_merge_ft($Subname) {
  return call_user_func($Subname);
}

Such functions should not do echo () but should return a string with the content to display.

The second way is to make a TBS plug-in. the principle is the same but customized fields will be automatically merged.