Categories > TinyButStrong general >

Outputing Defines

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: SarCaSM
Date: 2004-12-16
Time: 06:25

Outputing Defines

Wondering if it is at all possible to use the value of defines from php scripts in templates tinybutstrong.
By: Skrol29
Date: 2004-12-16
Time: 15:40

Re: Outputing Defines

Hello,

What is a define?
By: SarCaSM
Date: 2004-12-16
Time: 15:44

Re: Outputing Defines

Like this

<?php define('SOMETHING','Value Goes here'); ?>
By: Skrol29
Date: 2004-12-16
Time: 16:28

Re: Outputing Defines

Ha ok, they are user constants.

Contsnats are not available like Php Global Variables but you can display them doing the following:
Html:
  ... [cst.my_constant1] ...
  ... [cst.my_constant2] ...
Php:
$TBS->MergeField('cst','f_found_cst',true);
...
function f_found_cst($str) {
  return constant($str);
}

I will add this in the Tips & Tricks.
By: SarCaSM
Date: 2004-12-16
Time: 16:31

Re: Outputing Defines

Thanks Skrol! Now, do I need to have the f_found_cst function in my code? or this is something you have in TBS already?
By: Skrol29
Date: 2004-12-16
Time: 16:44

Re: Outputing Defines

You have to code it in your application.
This example illutsrates the MergeField() call with a user function.
You can change 'f_found_cst' to any other function name, but the function must exist in your application.
By: SarCaSM
Date: 2004-12-16
Time: 16:47

Re: Outputing Defines

ok, sounds good to me.  Thanks again!
By: Ed
Date: 2005-10-30
Time: 15:57

Re: Outputing Defines

In a related topic, how about if in:

PHP:
$TBS->MergeField('var','f_found_var',true);
...
function f_found_var($str) {
  return constant($str);
}

where:
var is a variable and i want to use a class method instead of a regular function for f_found_var

What TBS statements i need to  add inside the class method and how to declare var in the template?
By: Skrol29
Date: 2005-10-31
Time: 01:11

Re: Outputing Defines

Hi Ed,

This is possible using the Object Oriented Programing syntax.
Described here:
  http://www.tinybutstrong.com/manual.php#php_oop
By: Ed
Date: 2005-10-31
Time: 04:42

Re: Outputing Defines

Thanks. I read that already and honestly i need example. I guess, i had to do my homework first. I need to code first an example to reflect the scenario i want and discuss to you on specifics. will be back..thanks again