Categories > TinyButStrong general >

subtpl and tplvars

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: ziki
Date: 2006-07-05
Time: 05:20

subtpl and tplvars



in html tpl use a php script and set some tplvars
----------------------------------------------------------
my.html

[onload;tplvars;script_name=[var..script_name];script=html.php;subtpl]

---------------------------------------------------------
in html.php
$script_name = $TBS->TplVars['script_name'];
if($script_name == "myscript.php"){
   echo "yes";
}else{
   echo "no";
}

result :no

if in tpl use

[onload;tplvars;script_name='myscript.php';script=html.php;subtpl]
ruseut is yes
TBS version is 3.1.0
Why??
By: Skrol29
Date: 2006-07-05
Time: 10:09

Re: subtpl and tplvars

Hi Ziki,

This is because [var] fields are merged on the Show() method, so it's after [onload] fields. Some parameters like "if" can merge them on the fly.
In fact, in your PHP script, you have :
  $script_name == "[var..script_name]"

By the way, it seems to have no use to set a PHP variable in TplVars at the HTML side since you can do it at the PHP side.
$TBS->TplVars['script_name'] = $_SERVER['SCRIPT_NAME'];
This is not exactly the same value as [var..script_name] but it can be used the same way.
By: ziki
Date: 2006-07-05
Time: 10:21

Re: subtpl and tplvars

But I do use it(tplvars;myparameter=[var.temp]) to pass others parameter from html tplvars

var.temp is method by the mother script name

I want the sub script in tpl know the parameter

How to do?

Thanks
By: ziki
Date: 2006-07-05
Time: 10:27

Re: subtpl and tplvars

But I do want use it(tplvars;myparameter=[var.temp]) to pass others parameter from html tplvars

var.temp is merged by the mother script name

I want the sub script in tpl can  get  the parameter`s value

How to do?

Thanks
By: Skrol29
Date: 2006-07-05
Time: 13:52

Re: subtpl and tplvars

Can you give more details because I cannot see what you're trying to do ?
By: ziki
Date: 2006-07-05
Time: 15:52

Re: subtpl and tplvars

OK
I use it like this

first there is a editor.php is some script use FCKeditor
it needs some parameters
----------------------------------------------------------------------------
$textarea_name      =      $TBS->TplVars['textarea_name'];
$textarea_value          =      $TBS->TplVars['textarea_value'];

textarea($textarea_name,$textarea_value);


function textarea($textarea_name=null,$textarea_value=null,$editor=null,$textarea_width=null,$textarea_height=null){
    if($editor == null){
       
        $sBasePath = "../WEB-INF/lib/FCKeditor/";
        if($textarea_name !=null){
            $oFCKeditor = new FCKeditor($textarea_name) ;
        }else{
            $oFCKeditor = new FCKeditor('FCKeditor1') ;
        }
        $oFCKeditor->BasePath    = $sBasePath ;
       
        if($textarea_value !=null){
        $oFCKeditor->Value        = $textarea_value ;
        }else{
        $oFCKeditor->Value        = '' ;       
        }
        $oFCKeditor->Height        = 300 ;
        $oFCKeditor->Create() ;
    }
}

------------------------------------------------------------------------------

use the editor.php

[onload;tplvars;textarea_name='content';textarea_value=[var.value.ontent];script=editor.php;subtpl]

so the Fckedor have some parameters to Construction a Fckeditor has what I want to render
By: ziki
Date: 2006-07-05
Time: 15:58

Re: subtpl and tplvars

use the editor.php
in a tpl
------------------------------------------
edit_product.html


[onload;tplvars;textarea_name='small_image';textarea_value=[var.value.small_image];script=editor.php;subtpl]

[onload;tplvars;textarea_name='big_image';textarea_value=[var.value.big_image];script=editor.php;subtpl]

[onload;tplvars;textarea_name='content';textarea_value=[var.value.ontent];script=editor.php;subtpl]

so I do not use
[onload;script=small_image_editor.php;subtpl]
[onload;script=bigl_image_editor.php;subtpl]
[onload;script=content_editor.php;subtpl]

do you unstand me? :)


By: Skrol29
Date: 2006-07-05
Time: 20:27

Re: subtpl and tplvars

Ok, I understand,

You need "textarea_value" in the subscript and that it depend of the ain template. However your way is strange because you first insert from PHP to the template, and then taking it from the template to PHP. I'm not surpise that it is not easy to do with a Template Engine.

Here a solution to do the same:
HTML:
[onload;tplvars;textarea_name='content';textarea_value=content;script=editor.php;subtpl]
PHP:
$textarea_name   =   $TBS->TplVars['textarea_name'];
$textarea_value    =   GLOBALS['value'][$TBS->TplVars['textarea_value']];

Or more simple:
HTML:
[onload;tplvars;textarea_name='content';script=editor.php;subtpl]
PHP:
$textarea_name   =   $TBS->TplVars['textarea_name'];
$textarea_value    =   GLOBALS['value'][$textarea_name];
By: ziki
Date: 2006-07-06
Time: 02:22

Re: subtpl and tplvars

Thanks first

But I copy your code to my script

it does not work well

how to use GLOBALS['value']?

By: Skrol29
Date: 2006-07-06
Time: 13:04

Re: subtpl and tplvars

It is $GLOBALS, not GLOBALS, sorry.