Categories > OpenTBS with DOCX >

OpenTBS newbie qn: How to get an extra field into the demo docx file

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: sam
Date: 2009-12-23
Time: 09:36

OpenTBS newbie qn: How to get an extra field into the demo docx file

Hi all,
This is a simple qn.
Here I have a php file that works fine.
But I'd like to introduce a second variable besides the:
$yourname="Bob Jones";
For example I might want:
$yourtitle="Mr";

But when I put a field in the word dodx docuement like [onshow.yourname]
I get the error:
TinyButStrong Error in field [onshow.yourtitle] This message can be cancelled using parameter 'noerr'.
How do I make it work?

Also how do I change "onshow" to "mm" when inserted as a variable in word. e.g [onshow.yourtitle]  works. But I'd like it to me [mm.yourtitle]

Here is the php file that works with only the [onshow.yourtitle] varialble:
<?php
// Display this code source is asked.
if (isset($_GET['source'])) exit(highlight_file(__FILE__,true));

// Libraries
include_once('tbs_class.php'); // TinyButStrong template engine
include_once('tbs_plugin_opentbs.php'); // OpenTBS plugin

$TBS = new clsTinyButStrong; // new instance of TBS
$TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN); // load OpenTBS plugin

$template = "samsdem1.docx";
$yourname="Bob Jones";

$TBS->LoadTemplate($template); // Define the name of the output file
$file_name = str_replace('.','_'.date('Y-m-d').'.',$template);  // Define the name of the output file


$TBS->Show(OPENTBS_DOWNLOAD+TBS_EXIT, $file_name);
//$TBS->Show(OPENTBS_FILE+TBS_EXIT, $file_name);

?>
By: sam
Date: 2009-12-23
Time: 10:37

Re: newbie qn: How to get an extra field into the demo docx file

I found out that I started the docx file with the parameter and not some other text. As long as I have at least a space as the first character in the word document then it works.
If I start it with [onshow.yourname]  then theres errors with the second variable

Is this a bug or am I missing something?

thanks
Sam

By: Skrol29
Date: 2009-12-23
Time: 18:00

Re: newbie qn: How to get an extra field into the demo docx file

Hi Sam,

Your have this behavior probably because Ms Word cut the TBS field is several parts in its file source (.docx\word\document.xml). Word does that kind of stuff because of the spellchecker, or the autocorrect feature. Those can be deactivated but the text is steel cut sometimes.

You can check the "document.xml" to see what appended to your text.