Categories > TinyButStrong general >

Move errors

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: martijn
Date: 2007-04-05
Time: 17:00

Move errors

Hi,
Is it possible to output template errors (TinyButStrong Error:...) not at the very top of the generated page, but between the body tags (for validation and stuff like that) instead?
Thanks in advance!
martijn
By: Skrol29
Date: 2007-04-05
Time: 18:10

Re: Move errors

Hi,

No sorry, this is not possible.
TBS doesn't know it's merging a page with a <body> part. The template can be different, even if your are merging HTML.

But you can capture the output error message and inster them in the template if needed. TBS has a property now which tells you how many errors have been met, with of without silent mode.
By: martijn
Date: 2007-04-05
Time: 18:16

Re: Move errors

How could I capture that, then?
By: Skrol29
Date: 2007-04-05
Time: 20:19

Re: Move errors

See PHP function ob_start().
By: martijn
Date: 2007-07-02
Time: 20:03

Re: Move errors

Hi, I've finally got back at this.
I took a look some articles about output buffering, but I'm still having problems understanding how I could use TBS in conjunction with this.
Also, I'd like to include this in a class that hooks in as a plugin (merging certain items beforehand so they are globally available) instead of having to use ob_start and ob_end at the start/end of every script.
Is this possible?
With regards,
martijn
By: Skrol29
Date: 2007-07-04
Time: 00:28

Re: Move errors

Hi,

Here is an example of what can be done (not tested).
I think this can be done as a plug-in.

ob_start(); // Sart output buffering

$TBS = new clsTinyButStrong();
$TBS->LoadTemplate(...);
$TBS->MergeBlock(...);
$TBS->Show(TBS_NOTHING); // Merges [var] and [onshow]

$err_msg = ob_get_contents(); // Get buffered string which should be only errors
ob_end_clean(); // Stop buffering

$TBS->MergeField('err_msg',$err_msg); // Display errors in a TBS field like [err_msg] in the template.
echo $TBS->Source; // Display the result