Categories > TinyButStrong general >

Merging not working

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: martijn
Date: 2007-02-28
Time: 20:49

Merging not working

Hi all,
I'm trying to code a page for my site that displays only one row from a database record.
This page fetches the id-code from a GET variable called 'id'.
However, this variable may only contain numerical characters, so I have set up some error checking.
My problem however is that while I am able to use the passed id-number to fetch the name of the, in my case, software release and put it into a variable for the page title, it seems not to be working in a MergeBlock function (..WHERE id=$id).
The TBS tag for the block doesn't get parsed, it seems.

Here's my code.
PHP-side:
        
case 'release':
            $parse = "";                    //    Initiate the variable
            $state = "";                    //    Ditto
           
        if(!isset($_GET['id'])){                        //    Have we got a id global variable passed or not?
            $state = 0;                                    //    Set status to zero
            $parse = 0;                                    //    Set get variable to zero
            $page_title = $portal->pageTitle('Error');    //    Error page
        }
        else{                                        //    Yes, it's set
            if(is_numeric($_GET['id']) == TRUE){            //    Numerical
                $title = $sql->Value('0', 'SELECT name FROM `files_releases` WHERE (id=%1%)', $_GET['id']);
                if($title != '0'){
                    $state = 1;                            //    Set status to one, like a kind of switch for the template
                    $parse = $_GET['id'];                //    Set parse variable to get variable

                    $page_title = $portal->pageTitle($title);    //    Set the page title to what the database returns
                    $tmpl->MergeBlock('relfile', 'mysql',"SELECT name, version, description FROM `files_releases` WHERE id=$parse");
                }
                else{
                    $state = 0;
                    $page_title = $portal->pageTitle('Error');
                }
            }
           
            else{                                            //    Not numerical
                $state = 0;                                    //    Set status to zero
                $parse = 0;                                    //    Set parse variable to zero
                $page_title = $portal->pageTitle('Error');    //    Error page
            }
           
        }
        $tmpl->LoadTemplate('files.html');        // Load the template file
    break;
Template-side:
    [onload;file=[var..cst.TPL_PATH]\header.html]
        <div class="content">
            [onload_state;block=div;when [var.state] == 0]
            <h3 class="wimg">[var.page_title;htmlconv=no]</h3>
        </div>
        <div class="content">
            [onload_state;block=div;when [var.state] == 1]
            <h3 class="wimg">[var.page_title;htmlconv=no]</h3>
            <p>[relfile.description]</p>
        </div>
    [onload;file=[var..cst.TPL_PATH]\footer.html]

Thanks in advance for any help!
martijn
By: martijn
Date: 2007-03-04
Time: 15:08

Re: Merging not working

Sorry, but I really need to know what I did wrong with above code, since it seems ok to me.
By: TomH
Date: 2007-03-04
Time: 16:07

Re: Merging not working

Sorry if this is just a suggestion to do what you've already done to debug...

Independently verify that the mysql stmt in the MergeBlock actually is returning a value. Maybe add another var...
...
$parse= $_GET['id']; ;
$result = $sql->Value('0', 'SELECT name, version FROM `files_releases` WHERE (id=%1%)', $parse);
$debug = print_r($result, true);
Then add a display line to the HTML
...
Test MergeBlock query: [var.debug]
...

Otherwise, try placing the LoadTemplate before the MergeBlock ;)


By: martijn
Date: 2007-03-04
Time: 16:12

Re: Merging not working

I tried that, also changing location, but it didn't help.
And now it also fails rendering completely on that section.
Everything just gets thrown out like this:
[onload;file=[var..cst.TPL_PATH]\header.html]
[onload_state;block=div;when [var.state] == 0]
[var.page_title;htmlconv=no]
[onload_state;block=div;when [var.state] == 1]
[var.page_title;htmlconv=no]

[relfile.description]
[onload;file=[var..cst.TPL_PATH]\footer.html]
Rest of this site renders correctly. I'm perplexed by this :S
By: martijn
Date: 2007-03-04
Time: 16:27

Re: Merging not working

Never mind, I saved it in a wrong encoding by mistake.
And the tip on placing LoadTemplate before MergeBlock did the trick, too.
Thanks!