Categories > TinyButStrong general >

Include file or write text

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: RwD
Date: 2003-12-27
Time: 02:41

Include file or write text

I have two columns in a MySQL table.  ->
page_template : Either 'default' or the name of a existing template file
page_content : Content of the current page (may not be displayed depending on settings...)

And I want to do the following:
if (page_template != 'default')
then include page_template
else display page_content

My closest tbs guess would be the following:
{box.page_template;if {val}!='default';file={var._dir_templ}{val}; else {box.page_content}; htmlconv=look;protect=no}
(although this is wrong it does show you what I want to achieve)

(the tbs guess gets processed by this call:
$tbs->MergeBlock('box','mysql',$query);)


How can I achieve this?????
By: RwD
Date: 2003-12-27
Time: 03:07

Re: Include file or write text

I came just a bit closer myself, but it still isn't as it should be!!

{tbs_check;if {box.page_template}='default'}
    {box.page_content;htmlconv=look;protect=no}
{tbs_check;else}
    {box.page_template;file={var._dir_templ}{val}; htmlconv=look; protect=no}
{tbs_check;endif}

However, in this way tbs tries to get the templates in the 'else' statement, even though at this point it is unknown if that is needed at all.

I cannot evaluate the check first because this block is copied for as  many records the query yields;
the box fields are within a table that among others also holds the locator {box.page_box_title;ifempty={box.page_title};block=table}  (sorry, forgot to mention that in the previous post)
By: RwD
Date: 2003-12-27
Time: 03:33

Re: Include file or write text

Ok, I added the file 'default' to the template dirctory, then I losse the error message, but I would like to know any better method...
By: Skrol29
Date: 2003-12-29
Time: 01:17

Re: Include file or write text

Hello RwD,

If you have the 1.90bx version, then you can use a custom PHP function on the block using the 'onsection' parameter.

With previous versions, or with the same version, you can also use something like this:
{box.page_template;file={val};if '{val}'!='default'}
{box.page_content;htmlconv=look;protect=no;if '{box.page_template}'='default'}
Because there is a nested TBS field, you have to be sure that in your query, the 'page_template' column comes before the 'page_content' column.

Your code the tbs_check can't work because tbs_check tags without sub-names are processed like fields and not like blocks.
It is not a good solution anyway because it first displays all contents (both page_template and page_content) and then deletes the bad ones. Which is not the fastest way.