This module allows your clients to manage text and images in-place, but in the admin interface.
The default action is what is used to mark an element (string or HTML text) as editable. It should be put inside the element tag. This action requires the following parameters:
- name: the name by which you want to identify this element
- type: 'string', 'text' or 'thumbnail'
- width: the width a thumbnail should have
- height: the height a thumbnail should have
- sitewide: boolean, if true the element can be used on more than one pages
The default action will complete your HTML tag, but also assign the currently set value to the variable $value. You can work with default values by either using an if operator or by using the smarty 'default' modifier. Examples of both are given below, however for HTML text it is probably easier and clearer coding by using the if operator. For string elements, $value will be processed by htmlentities so you don't need to do this in your code.
String value with a default value coded with the if operator
<h1{InlineEditor name="title" type="string"}>{if $value}{$value}{else}My default title{/if}</h1>
String value with a default value coded with the Smarty modifier
<p class="subtitle"{InlineEditor name="subtitle" type="string"}>{$value|default:"My default subtitle"}</p>
Note: for HTML text you should set the editing on a wrapping div as seen below:
<div class="contents"{InlineEditor name="subtitle" type="text"}>
{if $value}{$value}{else}
<p>Nothing set, so we use a default text for this paragraph.</p>
<p>And another paragraph so our placeholder text isn't too short.</p>
{/if}
</div>
Thumbnail
<a href="{InlineEditor action="thumbnail" original=true name="mythumb" default="$site_url/images/image1.large.jpg"}">
<img src="{InlineEditor action="thumbnail" name="mythumb" default="$site_url/images/image1.small.jpg"}" alt=""{InlineEditor name="mythumb" type="thumbnail" width=200 height=120}>
</a>
This is separated from the other two editing options (string and HTML text) as it will output the URL to the image (either the original image or the generated thumbnail). Parameters are the following:
- name: the name by which the thumbnail is identified
- original: set this to TRUE to get the URL to the original image instead of the generated thumbnail (optional parameter)
- default: optional parameter to define an URL to be outputted if no image has been uploaded yet
See the example above under the default action.
This action will simply output the value for a certain element. For string elements, the value will be processed by htmlentities so you don't need to do this in your code. The parameters for this action are the following:
- name: the name by which the element is identified
- default: a default value which will be outputted if no value is set for the element
<p class="subtitle">{InlineEditor action="value" name="subtitle" default="My default subtitle"}</p>
It is possible to edit properties of a Map object, but only if they are one of the three supported types (string, text and thumbnail).
<div{InlineEditor map="MapProduct" property="text" id=$product->getId()}>{$product->text}</div>
It is possible to highlight certain elements for editing, but have the user redirected to another module to actually do it.
Just use the default action but specify the redirect parameter as ".". If you simply specify a module the action will be set to defaultadmin. All other parameters given at this point will be passed through to the other module.
<ul class="list-1 openinghours"{InlineEditor redirect="OpeningHours"}>{OpeningHours location=1}
{foreach $openinghours.hours as $record}
<li>
<span>{$record.from|ucfirst|escape}{if !empty($record.until)} {if $record.diff > 1}tot{else}en{/if} {$record.until|escape}{/if}:</span>
{if empty($record.times)} gesloten.{else}
{foreach $record.times as $time}{if $time@first} {/if}{if $time@last && $time@total > 1} en {/if}{$time.from} tot {$time.until}{if $time@iteration < $time@total -1}, {/if}{/foreach}
{/if}
</li>
{/foreach}
</ul>
{if $openinghours.exception}<p class="closed"{InlineEditor redirect="OpeningHours" tab="exceptions"}><strong>Wij zijn gesloten van {$openinghours.exception.from|cms_date_format:'%e %B'|strtolower} tot en met {$openinghours.exception.until|cms_date_format:'%e %B'|strtolower}{if !empty($openinghours.exception.reason)} wegens {$openinghours.exception.reason|strtolower|escape}{/if}.</strong></p>{/if}