Categories > TinyButStrong general >

More than one parameter for functions

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Uranellus
Date: 2005-08-13
Time: 00:51

More than one parameter for functions

In the docu there is already a function for multilanguage demonstrated, but after some trying I come to a point where I need more than one parameter for some functions to work.
function get_link($document, $text = "", $target = "", $qstring = "", $getsid = true)
Right now I can just give the first parameter, is there a poss. to give more than the first parameter.

I have an Idea myself, but that would be more a workaround which I do not like so much. My idea was to write a small function which would call a function and the parameters would be seperated by an explode.

Greetings!
My apology if I havent found such an information in the docs/forum/faqs or elsewhere.
Uranellus
By: Uranellus
Date: 2005-08-13
Time: 00:56

Re: More than one parameter for functions

I forgot to mention the HTML/TBS side:
$TPL->ObjectRef['ses'] = &$ses;
$TPL->MergeField("link","~ses.get_link",true);
My goal would be (Template:)
[link.index.php.Home]
Or something compareable.
Thanke for your help/support :)
Greetz
Uranellus
By: Skrol29
Date: 2005-08-13
Time: 09:33

Re: More than one parameter for functions

Hi,

the function for MergeField can have the syntax
  get_link($field_name)
or
  get_link($field_name,$PrmLst)
where $PrmLst is the array of parameters of the field currently merged.
You can use this syntaxe to retrieve parameters in a filed like this:
  [link.index.php.home;text=aaa;target=bbb;qstring='select...';getsid=1]


By: Uranellus
Date: 2005-08-14
Time: 00:38

Re: More than one parameter for functions

Thanks for the great support!!!
If someone else is having a similar problem I'm going to post my snippet.
Thanks again for the support and for the great script!
Uranellus

PHP:
class mySes extends Sessionara
{
    function my_get_link ($field_name,$PrmLst)
    {
//function get_link($document, $text = "", $target = "", $qstring = "", $getsid = true) {
        return $this->get_link($PrmLst['document'],$PrmLst['text'],$PrmLst['target'],$PrmLst['qstring'],$PrmLst['getsid']);
    }
}

$ses = new mySes("W/MYSQL");
$TPL->ObjectRef['ses'] = &$ses;
$TPL->MergeField("link","~ses.my_get_link",true);
HTML:
[link;document=index.php;text=aaa;qstring='site=index.php&action=a';htmlconv=no+wsp]