As mentioned already before, Pimcore uses Zend_View as its template engine, and the standard template language is PHP.
The Pimcore implementation of Zend_View offers special methods to increase the usability:
| Method | Description |
|---|---|
| inc |
Use this function to directly include a document |
| template |
Use this method to include a template |
| cache |
In template caching |
| translate |
i18n / translations |
| glossary |
Glossary |
Additionally you can use the Zend_View helpers which are shipped with ZF. There are some really cool helpers which are really useful when used in combination with Pimcore.
Some Examples
You can use your own custom Zend_View helpers, or create some new one to make your life easier.
There are some properties which are automatic available in the view:
| Name |
Type |
Description |
|---|---|---|
| editmode |
boolean |
Is true if you are in editmode (admin), false if you are on the website |
| controller |
Pimcore_Controller_Action_Frontend |
A reference to the controller |
| document |
Document |
Reference to the current document object you can directly access the properties of the document in the view (eg. $this?document?getTitle();) |
Editables (Placeholders for content)
Pimcore offers a basic set of placeholders which can be placed directly into the template. In editmode they appear as an editable widget, where you can put your content in. While in frontend-mode the content is directly embedded into the HTML.
There is a standard scheme for how to call the editables. The first argument is always the name of the element (as string), the second argument is an array with multiple options (configurations) in it.
Because most of the elements are based directly on Ext.form elements, you can also pass configurations directly to the Ext components (see API reference of Ext)
Click here to get a detailed overview about the editables.
Example
<!-- creates a input in editmode (admin) and directly outputs the text in frontend --> <h1><?= $this->input("headline", array("width" => 540)); ?></h1> <!-- advances template --> <?php $this->layout()->setLayout('standard'); ?> <h1><?= $this->input("headline", array("width" => 540)); ?></h1> <h1><?= $this->numeric("number", array("width" => 540)); ?></h1> <?php while ($this->block("contentblock")->enumerate()) { ?> <?php if($this->editmode) { ?> <?= $this->select("blocktype",array( "store" => array( array("wysiwyg", "WYSIWYG"), array("contentimages", "WYSIWYG with images"), array("video", "Video") ), "onchange" => "editWindow.reload.bind(editWindow)" )); ?> <?php } ?> <?php if(!$this->select("blocktype")->isEmpty()) { $this->template("content/blocks/".$this->select("blocktype")->getData().".php"); } ?> <?php } ?>
Comments (1)
Nov 04, 2010
Tim Glabisch says:
if you want your plugin to has access to the website templates, you can use some...if you want your plugin to has access to the website templates, you can use something like this:
$this->view->setScriptPath(
array_merge(
$this->view->getScriptPaths(),
array(
_DIR_.'/../../../website/views/scripts/',
_DIR_.'/../../../website/views/layouts/'
)
)
);
please mind to use fixed path's because if you develop a plugin, you don't know anything about the content in the website dir.