ProcessWire - Front Page Editing: Unterschied zwischen den Versionen
(Die Seite wurde neu angelegt: „ https://processwire.com/docs/front-end/front-end-editing/ * Mehrere Optionen * Option A -> Automatisch ** Kann verwendet werden wenn ein Feld nur einmal auf…“) |
|||
| Zeile 1: | Zeile 1: | ||
https://processwire.com/docs/front-end/front-end-editing/ | https://processwire.com/docs/front-end/front-end-editing/ | ||
| − | * Mehrere Optionen | + | * Mehrere Optionen (im Backend auswählen) |
* Option A -> Automatisch | * Option A -> Automatisch | ||
** Kann verwendet werden wenn ein Feld nur einmal auf einer Seite verwendet wird. | ** Kann verwendet werden wenn ein Feld nur einmal auf einer Seite verwendet wird. | ||
| Zeile 7: | Zeile 7: | ||
** Geeignet für text fields, number fields, dates... | ** Geeignet für text fields, number fields, dates... | ||
** Nicht geeignet für Files/Images, PageTables, Repeaters or andere Felder über die man iteriert | ** Nicht geeignet für Files/Images, PageTables, Repeaters or andere Felder über die man iteriert | ||
| + | ** Statt get einfach edit nehmen | ||
| + | <?php echo $page->edit('body'); ?> | ||
* Option C -> HTML Edit Tags | * Option C -> HTML Edit Tags | ||
| + | ** Anhand ''<edit [feldname]>...</edit>'' findet PW die Felder | ||
| + | ** Für Repeater geeignet | ||
| + | |||
* Option D -> HTML Edit Attributes | * Option D -> HTML Edit Attributes | ||
| + | ** Gleiche Funktionalität wie Tags | ||
| + | ** edit Attribut für div, span, ... statt eigenständiges Tag | ||
| + | <div edit="events">...</div> | ||
| − | Option A | + | == Options in Detail == |
| + | === Option A === | ||
Einfach im Backend anhaken | Einfach im Backend anhaken | ||
| + | |||
| + | === Option B === | ||
| + | |||
| + | === Option C === | ||
| + | |||
| + | Beispiel Image Feld 'photo' | ||
| + | <syntaxhighlight lang="php"> | ||
| + | <edit photo> | ||
| + | <img src="<?=$page->image->url?>" /> | ||
| + | </edit> | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | Beispiel Repeater, PageTable oder Table Field | ||
| + | <syntaxhighlight lang="php"> | ||
| + | <edit events> | ||
| + | <?php foreach($page->events as $event): ?> | ||
| + | <div class="event"> | ||
| + | <h3><?=$event->title?></h3> | ||
| + | <p class="date"><?=$event->date?></p> | ||
| + | <p><?=$event->summary?></p> | ||
| + | </div> | ||
| + | <?php endforeach; ?> | ||
| + | </edit> | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | Beschreibung von Ryan: | ||
| + | |||
| + | By the way, you can also use some more verbose but alternate syntax for the <edit> tags if you prefer. If your editor does syntax highlighting with your HTML, it may be more consistent (the "quotes" are optional of course): | ||
| + | |||
| + | <edit field="events"> ... </edit> | ||
| + | If your editable region contains multiple fields you want to be edited together, you can specify more than one: | ||
| + | |||
| + | <edit field="intro,image,events"> ... </edit> | ||
| + | If your field happens to be on some other page other than the one being rendered, you can also specify what page you want to be edited: | ||
| + | |||
| + | <edit field="events" page="1001"> ... </edit> | ||
| + | The 1001 can be any page ID or path. The above can also be shortened to this if you prefer: | ||
| + | |||
| + | <edit field="1001.events"> ... </edit> | ||
| + | Or this: | ||
| + | |||
| + | <edit 1001.events> ... </edit> | ||
| + | If you are using <edit> tags with a field that supports inline editing (like a text or CKEditor field), the inline editor will be used. Otherwise it will open a dialog to the editor. | ||
| + | |||
| + | === Option D === | ||
| + | <syntaxhighlight lang="html5"> | ||
| + | <div edit="events"> | ||
| + | <!-- code to output events --> | ||
| + | </div> | ||
| + | </syntaxhighlight> | ||
| + | Or to specify a field from some other page (1001): | ||
| + | |||
| + | <syntaxhighlight lang="html5"> | ||
| + | <div edit="1001.events"> ... </div> | ||
| + | </syntaxhighlight> | ||
| + | Or to specify multiple fields: | ||
| + | |||
| + | <syntaxhighlight lang="html5"> | ||
| + | <div edit="intro,image,events"> ... </div> | ||
| + | </syntaxhighlight> | ||
| + | The "edit" attributes are stripped from the markup that gets output, so the only place you will see them is where you place them in your template file(s). | ||
| + | |||
| + | Worth noting about option D is that it always uses the dialog editor and does not use the inline editor. | ||
Version vom 20. Juli 2020, 20:29 Uhr
https://processwire.com/docs/front-end/front-end-editing/
- Mehrere Optionen (im Backend auswählen)
- Option A -> Automatisch
- Kann verwendet werden wenn ein Feld nur einmal auf einer Seite verwendet wird.
- Option B -> API Method Call
- Geeignet für text fields, number fields, dates...
- Nicht geeignet für Files/Images, PageTables, Repeaters or andere Felder über die man iteriert
- Statt get einfach edit nehmen
<?php echo $page->edit('body'); ?>
- Option C -> HTML Edit Tags
- Anhand <edit [feldname]>...</edit> findet PW die Felder
- Für Repeater geeignet
- Option D -> HTML Edit Attributes
- Gleiche Funktionalität wie Tags
- edit Attribut für div, span, ... statt eigenständiges Tag
Options in Detail
Option A
Einfach im Backend anhaken
Option B
Option C
Beispiel Image Feld 'photo'
<edit photo>
<img src="<?=$page->image->url?>" />
</edit>
Beispiel Repeater, PageTable oder Table Field
<edit events>
<?php foreach($page->events as $event): ?>
<div class="event">
<h3><?=$event->title?></h3>
<p class="date"><?=$event->date?></p>
<p><?=$event->summary?></p>
</div>
<?php endforeach; ?>
</edit>
Beschreibung von Ryan:
By the way, you can also use some more verbose but alternate syntax for the <edit> tags if you prefer. If your editor does syntax highlighting with your HTML, it may be more consistent (the "quotes" are optional of course):
<edit field="events"> ... </edit>
If your editable region contains multiple fields you want to be edited together, you can specify more than one:
<edit field="intro,image,events"> ... </edit>
If your field happens to be on some other page other than the one being rendered, you can also specify what page you want to be edited:
<edit field="events" page="1001"> ... </edit>
The 1001 can be any page ID or path. The above can also be shortened to this if you prefer:
<edit field="1001.events"> ... </edit>
Or this:
<edit 1001.events> ... </edit>
If you are using <edit> tags with a field that supports inline editing (like a text or CKEditor field), the inline editor will be used. Otherwise it will open a dialog to the editor.
Option D
<div edit="events">
<!-- code to output events -->
</div>
Or to specify a field from some other page (1001):
<div edit="1001.events"> ... </div>
Or to specify multiple fields:
<div edit="intro,image,events"> ... </div>
The "edit" attributes are stripped from the markup that gets output, so the only place you will see them is where you place them in your template file(s).
Worth noting about option D is that it always uses the dialog editor and does not use the inline editor.