Practical phppptx

HTML and CSS

Introduction

phppptx can transform HTML and CSS to add new contents in slides.

HTML and CSS

addHtml is the method to add HTML:

This method includes the following parameters:

  • $html: HTML/CSS to transform.
  • $position: position to add the new content. This can be an existing placeholder in the layout or a new text box.
  • $options: array to set extra options.

The following code adds HTML contents applying CSS styles:

Replacing variables in templates

When working with a template, replaceVariableHtml allows to replace a placeholder with HTML:

The available parameters are:

  • $variables: placeholders to be replaced
  • $options: it's an array which can have these keys:
    • 'activeSlide' (bool): if true, get only the active slide. Default as false.
    • 'target' (string): slides (default).
    • 'type' (string): inline (only replaces the variable), block (default, removes the variable and its containing paragraph).

After loading the template, an easy replacement would be:

This code changes the placeholder VAR by a paragraph with the text "phppptx".

Tips and tricks

Install and enable Tidy and mbstring PHP extensions to transform HTML.

Next - Tables