masu_dev
masu_dev

Reputation: 3

Variables are not relplaced in master slide layouts with OpenTBS

I am trying to use OpenTBS to change texts and images within PowerPoint files and use variables for this purpose. This works fine on slides, master slides but not on layouts belonging to the master slide.

The problem persists when using automatic field onload / onshow.

My code looks like this:

$tmp = array(
    "name" => "test name"
);

$TBS->Plugin(OPENTBS_SELECT_SLIDE, "1_title_blue", true);
$TBS->MergeField('tmp', $tmp);

It works with the following code for content inside the "Single Master Slide".

$TBS->Plugin(OPENTBS_SELECT_SLIDE, 1, true);
$TBS->MergeField('tmp', $tmp);

The hierarchy in the master slide is as follows

Single Master Slide / has [tmp.name] > replacement working 
- Layout 1 name: 1_title_blue / has [tmp.name] > replacement not working 
- Layout 2 name: 1_title_red / has [tmp.name] > replacement not working 
- Layout 3 name: ...
- ... 

I have read various parts of the documentation here and searched forums. However, I cannot find a way to access the layouts directly and get replacement working there ...

Upvotes: 0

Views: 50

Answers (1)

Skrol29
Skrol29

Reputation: 5552

OpenTBS does not recognize Layout subfiles in PPTX documents (yet). But you can process them manually as any XML subfiles :

Find all Layout subfiles in a PPTX:

$files = $TBS->Plugin(OPENTBS_GET_FILES);
$layouts = array();
foreach ($files as $file) {
    if (dirname($file) == 'ppt/slideLayouts') {
        $layouts[] = $file;
    }
}

Open a specific subfile and merge auto fields :

$TBS->PlugIn(OPENTBS_SELECT_FILE, 'ppt/slideLayouts/slideLayout1.xml');

Upvotes: 0

Related Questions