Skip to content

Commit

Permalink
Merge pull request #1 from jorisros/documentation/php2twig
Browse files Browse the repository at this point in the history
Documentation/php2twig
  • Loading branch information
jorisros committed Nov 5, 2017
2 parents ff364a3 + 0a27983 commit acfae0b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
Expand Up @@ -27,6 +27,9 @@ The select editable generates select-box component in Editmode.
The code below shows a select box in editmode,
in the frontend preview you will see simply the value of the chosen option.

<div class="code-section">


```php
<?php
if($this->editmode):
Expand All @@ -47,6 +50,23 @@ else:
<?php endif; ?>
```

```twig
{% if editmode %}
{{ pimcore_select("valid_for", {
"store": [
["one-month", "One month"],
["three-months", "Three months"],
["unlimited", "Unlimited"]
]
}) }}
{% else %}
<p>
{{ "Something is valid for" | trans }}:{{ pimcore_select("valid_for").getData() | trans }}
</p>
{% endif %}
```
</div>

Editmode:
![Select editable in editmode](../../img/editables_select_editmode_preview.png)

Expand All @@ -66,4 +86,4 @@ if($this->editmode):
...

endif;
```
```
Expand Up @@ -27,9 +27,14 @@ You have to create them the same way as other documents (pages).
| `isEmpty()` | bool | Whether the editable is empty or not. |

## Examples
<div class="code-section">

```php
// Define a place for a snippet to be dragged onto, advanced usage
<?= $this->snippet("mySnippet", ["width" => 250, "height" => 100]) ?>
```

```twig
{{ pimcore_snippet("mySnippet", {"width": 250, "height": 100}) }}
```
</div>
10 changes: 10 additions & 0 deletions doc/Development_Documentation/03_Documents/01_Editables/README.md
Expand Up @@ -5,9 +5,19 @@ They are the essential part of managing content in documents.

## Example Usage
The following code makes the `<h1>` headline editable in a document:

<div class="code-section">

```php
<h1><?= $this->input("headline") ?></h1>
```

```twig
<h1>{{ pimcore_input("headline") }}</h1>
```

</div>

Pimcore automatically displays an input widget in the edit mode and renders the content when accessing the document via the frontend.

## List of Editables
Expand Down

0 comments on commit acfae0b

Please sign in to comment.