TinyButStrong - the PHP Template Engine
Categories > TinyButStrong general >

Parameter 'noerr' Seems to Not Work in Certain Situations

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: Anthony
Date: 2012-04-26
Time: 20:00

Parameter 'noerr' Seems to Not Work in Certain Situations

I am getting this error message:

TinyButStrong Error in field [degreeblock.yearofstudy...]: item 'yearofstudy' is not an existing key in the array. This message can be cancelled using parameter 'noerr'.

TinyButStrong Error in field [degreeblock.semester...]: item 'semester' is not an existing key in the array. This message can be cancelled using parameter 'noerr'.

TinyButStrong Error in field [degreeblock.yearofstudy...]: item 'yearofstudy' is not an existing key in the array. This message can be cancelled using parameter 'noerr'.

TinyButStrong Error in field [degreeblock.semester...]: item 'semester' is not an existing key in the array. This message can be cancelled using parameter 'noerr'.

However, I have a 'noerr' parameter in the TBS tags, so what is my problem?

<h4 class="classYear">[degreeblock.yearofstudy;if [val]=1;then 'First';if [val]=2;then 'Second';if [val]=3;then 'Third';if [val]=4;then 'Fourth';if [val]=5;then 'Fifth';block=h4+div;parentgrp=yearofstudy;noerr] Year <span class="expand">-</span></h4>

<h5>Semester [degreeblock.semester;block=h5+ol;parentgrp=semester;noerr]</h5>
By: Skrol29
Date: 2012-04-26
Time: 23:11

Re: Parameter 'noerr' Seems to Not Work in Certain Situations

This is strange indeed,

Can you post or send to me a snippet to reproduce the problem?
By: Anthony
Date: 2012-04-27
Time: 03:53

Re: Parameter 'noerr' Seems to Not Work in Certain Situations

Here's the page template:


[onload;file=../global/header_global.html;noerr]
        <div id="wrapper">
            <div id="left_col">
                [onload;file=side_menu_academics.html;noerr]
            </div>
            <div id="right_col">
                <h2>[onshow.section_title; noerr], [degreeblock.ID;block=h2+h3+p+h3;headergrp=degree;noerr]</h2>
                <h3>About</h3>
                <p>[degreeblock.description;noerr]</p>
                <h3>Schedule of Classes</h3>
                <h4 class="classYear">[degreeblock.yearofstudy;if [val]=1;then 'First';if [val]=2;then 'Second';if [val]=3;then 'Third';if [val]=4;then 'Fourth';if [val]=5;then 'Fifth';block=h4+div;parentgrp=yearofstudy;noerr] Year <span class="expand">-</span></h4>
                <div class="courseBlock">
                <h5>Semester [degreeblock.semester;block=h5+ol;parentgrp=semester;noerr]</h5>
                    <ol>
                        <li><span class="courseName">[degreeblock.course_description;att=span#class;if ''='[val]';then '';else 'courseName';noerr][degreeblock.course; block=li;noerr]</span>
                            <span class="courseDescription">[degreeblock.course_description;noerr]</span></li>
                    </ol>
                </div>
            </div>
        </div>
        [onload;file=../global/footer_global.html;noerr]


Here's the section of the php script that determines which query is used. In one particular case, some of the fields are not used and so are not in the array.
I was planning to just modify my template to not display the section that uses those fields.

if (!file_exists($html)) {  // don't continue if html template not found
                PageNotFound();
                exit;
        }
        $TBS->LoadTemplate($html);
        // Connection to the database
        try {
            # MySQL with PDO_MYSQL and Set Connection to Use UTF-8
            $DBConn = new PDO("mysql:host=$dbhost;dbname=$dbname",
                    $dbuser, $dbpass,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
                   
            /*** set the error reporting attribute ***/
            $DBConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            if ($recordID == "C.W.D.") {
                $sql = "SELECT d.ID AS ID, d.name AS degree, d.description AS description, d.requirements AS requirements
                            FROM degrees d
                            WHERE d.ID = '" . $recordID . "' ";
            }
            else {
                $sql = "SELECT d.ID AS ID, d.name AS degree, d.description AS description, d.requirements AS requirements,
                                c.name AS course, c.description AS course_description,
                                dd.yearofstudy AS yearofstudy, dd.semester AS semester
                            FROM degrees d
                            INNER JOIN degrees_details dd ON dd.degreeID = d.ID
                            INNER JOIN courses c ON c.ID = dd.courseID
                            WHERE d.ID = '" . $recordID . "' " .
                            "ORDER BY dd.yearofstudy,dd.semester,dd.order";
            }
           

            $tbs_source = ($DBConn===false) ? 'clear' : $DBConn;
            // Merge data and close connection
            $TBS->MergeBlock('degreeblock', $tbs_source, $sql);
                       
            $TBS->Show();
By: Skrol29
Date: 2012-04-27
Time: 18:09

Re: Parameter 'noerr' Seems to Not Work in Certain Situations

Hi Anthony,

Thank you for your snippet, I've reproduced the bug.

The error is in the error message. In fact TBS means that "parentgrp=yearofstudy" and "parentgrp=semester" cannot be processed because the column does not exist.
This error cannot be fixed by "noerr".

I put this error message to be fixed in the todo.
By: Anthony
Date: 2012-04-27
Time: 18:52

Re: Parameter 'noerr' Seems to Not Work in Certain Situations

Ok, thanks for the info. I will revise either the template or php script to avoid the problem.
By: Anthony
Date: 2013-01-16
Time: 19:59

Re: Parameter 'noerr' Seems to Not Work in Certain Situations

Were you ever able to address this issue to get noerr to work properly in the situation describe in this thread?

Regards,
AB
By: Skrol29
Date: 2013-01-19
Time: 00:21

Re: Parameter 'noerr' Seems to Not Work in Certain Situations

Hi,

Can you check that this beta version does fixe the problem as expected ?

http://www.tinybutstrong.com/dl.php?f=tbs_beta.zip&s=2