Processwire - API: Unterschied zwischen den Versionen
Aus Wikizone
Steff (Diskussion | Beiträge) |
Steff (Diskussion | Beiträge) |
||
| Zeile 14: | Zeile 14: | ||
== Seiten erstellen == | == Seiten erstellen == | ||
https://processwire.com/talk/topic/352-creating-pages-via-api/ | https://processwire.com/talk/topic/352-creating-pages-via-api/ | ||
| + | |||
| + | |||
| + | === Tipps === | ||
| + | * save a page before '''adding files''' to it | ||
| + | * To '''add a single image''', you'd need to do ''$p->image = 'path/to/image.jpg'''; rather than ''$p->image('path/to/image.jpg')''. This is because there is no Page::image() function | ||
| + | * may need to add a '''$page->setOutputFormatting(false)''' | ||
Version vom 29. Oktober 2018, 15:31 Uhr
Allgemeine Tipps
- Wenn kein Zugriff auf das Pages Objekt möglich ist kann man über wire()->pages auf die Funktionen zugreifen.
ProcessWire - Seiten löschen
https://processwire.com/api/ref/page/delete/g/
// Delete pages named "delete-me" that don't have children
$items = $pages->find("name=delete-me, numChildren=0");
foreach($items as $item) {
$item->delete();
}
Seiten erstellen
https://processwire.com/talk/topic/352-creating-pages-via-api/
Tipps
- save a page before adding files to it
- To add a single image', you'd need to do $p->image = 'path/to/image.jpg; rather than $p->image('path/to/image.jpg'). This is because there is no Page::image() function
- may need to add a $page->setOutputFormatting(false)