Categories > TinyButStrong general >

passing onload var into to a block

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: TomH
Date: 2014-02-06
Time: 04:49

passing onload var into to a block

I really want to pass a variable into a block

So I thought "why no do it by onload .var  ?"
No luck... the output is not truncated after the 22 character - the full test string is passed through in the template.

I have this
$length_subject = 22 ;

[blk.subject; ope=max:[onload.length_subject];maxend=''; noerr;]

Any ideas about how to do this would be greatly appreciated - yes I went through the TBS Manual, that's where I got the onload.length_subject syntax

Thanks for TBS every day,

By: Sheepy
Date: 2014-02-06
Time: 06:15

Re: passing onload var into to a block

Works for me. Please make sure the variable is initialised before LoadTemplate.

$length_subject = 22;

$tbs = new clsTinyButStrong();
$tbs->Source = "[blk.subject; ope=max:[onload.length_subject];maxend=''; noerr;]";
$tbs->LoadTemplate( null );
//$tbs->MergeField( 'blk', [ 'subject' => '012345678901234567890123456798'] );
By: TomH
Date: 2014-02-10
Time: 04:39

Re: passing onload var into to a block (when caching)

Thanks for replying - your check revealed what I overlooked in my post above

This script is doing TBS CACHING of the template -- like this
$TBS->PlugIn(TBS_INSTALL, TBS_CACHE, $dir, $mask); 

$TBS->Render = TBS_NOTHING ;

$template = "display_rss_filebuilder_template.html";  // this is the raw template file that is loaded into TBS->Source

$template_source = file_get_contents($template); //read html table (with TBS block code)

$TBS->Source = "";  // this line makes SURE TBS->Surce starts out EMPTY  - IMPORTANT

$TBS->Source = $template_source; // load the template see Manual property Source
$TBS->LoadTemplate(null) ;

$TBS->MergeBlock('blk', 'array', 'merged' );    // try with th eraw data pre-sort

$TBS->PlugIn(TBS_CACHE, $cacheid, TBS_CACHENOW );
$TBS->Source="";    // this CLEARS THE TBS->Surce TO BE EMPTY  - IMPORTANT

So technically there's no explicit LoadTemplate() -- which I completely overlooked ;)

Since these vars are needed inside
[blk.subject; ope=max:[onload.length_subject];maxend=''; noerr;]

I seems to me that the need to be substituted before the MergeBlock() - but I have no idea of how to do that other than the (missing) LoadTemplate()

If you/anyone has any ideas that mihgt point me in the right direction it would be greatly appreciated

Thanks for TBS every day,