Categories > OpenTBS with ODT >

OpenTBS MergeField acting irregularly

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: John
Date: 2016-02-22
Time: 15:13

OpenTBS MergeField acting irregularly

I'm using OpenTBS to populate a fields in an .odt document template with information drawn from a database query. Oddly, in the resulting document only a few of the fields have been merged seemingly arbitrarily. For example there will be cases of a particular variable being inserted in one spot but not in another. I've used the onshow, onload. and var prefixes with no apparent difference in the output.
if(isset($_POST["searchButton"])) {
            $keyword = $_POST['keyword'];
            $choice = $_POST['choice'];
        if($choice == "company_name")
            $sql = $mysqli -> prepare("SELECT * FROM clients WHERE company_name LIKE ?");

        if($choice == "project_code")
            $sql = $mysqli -> prepare("SELECT * FROM clients WHERE project_code LIKE ?");

        $keyword = '%'.$keyword.'%';
        $sql -> bind_param('s', $keyword);
        $sql -> execute();
        $result = $sql -> get_result();
                print("<p>Select query failed</p>");
            else {
                if($result -> num_rows == 0)
                print("<p>No match found</p>");
            else {
                while($GLOBALS = mysqli_fetch_array($result)) {
                    $company_name = $GLOBALS['0'];
                    $phone = $GLOBALS['1'];
                    $address = $GLOBALS['2'];
                    $approximate_employees = $GLOBALS['3'];
                    $project_code = $GLOBALS['4'];
                $TBS = new clsTinyButStrong;
                $TBS -> Plugin(TBS_INSTALL, OPENTBS_PLUGIN);
                $TBS -> NoErr = true;               
                $template = 'document.odt';
                $TBS -> LoadTemplate($template, "OPEN_ALREADY_UTF8");
                $TBS -> MergeField('company_name', $company_name);
                $TBS -> MergeField('phone', $phone);
                $TBS -> MergeField('address', $address);

                $TBS -> Show(OPENTBS_FILE, 'new_document.odt');   

By: Skrol29
Date: 2016-02-22
Time: 23:39

Re: OpenTBS MergeField acting irregularly


Have you seen the chapter « Some TBS tags are not merged » in the updated document file?
By: John
Date: 2016-02-24
Time: 14:11

Re: OpenTBS MergeField acting irregularly

I had a look at the zip archive for the problematic document and there are some clear irregularities in the problem areas. Additionally, I've found other documents merge fields without issue. I think the problem is that the template I'm using is originally a heavily formatted word file which I'm opening through open office leading to the content.xml file's structure getting garbled. Thanks very much for your assistance in developing this application, you've been a great help!