You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hab mich gewundert, warum das Template mit meiner rex_article nicht richtig lief und "[art_title not found]" als Artikeltitel auswarf.
Die fragliche Code-Stelle im Template "00. Header" ist
// Use article title as title-Tag, unless a custom title-tag is set
if ($this->getValue("art_title") != "") {
$title = htmlspecialchars($this->getValue('art_title'));
} else {
$title = htmlspecialchars($this->getValue('name'));
}
Da "getValue("art_title") " bei nicht vorhandenem Meta-Feld "art_title" bereits in eine Exception läuft und "[art_title not found]" zurückliefert, ist auch die Abfrage auf "" wirkungslos. Mit
// Use article title as title-Tag, unless a custom title-tag is set
$title = $this->getValue("art_title");
if ( !$title || $title == '[art_title not found]' ) {
$title = htmlspecialchars($this->getValue('name'));
}
funktioniert es.
Grüße
Chris
The text was updated successfully, but these errors were encountered:
Die Prüfung auf $title == '[art_title not found]' würde ich allerdings vermeiden, weil sich die Fehlermeldung in zukünftigen REDAXO-Versionen ändern kann, und weil du den String zudem an jedes Metafeld anpassen musst. Etwas robuster und generischer ist es, wenn du mit hasValue() prüfst, bevor du getValue() benutzt. Beispiel:
// Use article title as title-Tag, unless a custom title-tag is setif ($this->hasValue("art_title") && $this->getValue("art_title") != "") {
$title = htmlspecialchars($this->getValue('art_title'));
} else {
$title = htmlspecialchars($this->getValue('name'));
}
Hallöle
hab mich gewundert, warum das Template mit meiner rex_article nicht richtig lief und "[art_title not found]" als Artikeltitel auswarf.
Die fragliche Code-Stelle im Template "00. Header" ist
Da "getValue("art_title") " bei nicht vorhandenem Meta-Feld "art_title" bereits in eine Exception läuft und "[art_title not found]" zurückliefert, ist auch die Abfrage auf "" wirkungslos. Mit
funktioniert es.
Grüße
Chris
The text was updated successfully, but these errors were encountered: