Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fehler im Header mit art_title #45

Closed
christophboecker opened this issue Jun 16, 2017 · 2 comments
Closed

Fehler im Header mit art_title #45

christophboecker opened this issue Jun 16, 2017 · 2 comments
Assignees

Comments

@christophboecker
Copy link
Member

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

	// 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

@schuer
Copy link
Member

schuer commented Aug 17, 2017

Danke!

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 set
if ($this->hasValue("art_title") && $this->getValue("art_title") != "") {
    $title = htmlspecialchars($this->getValue('art_title'));
} else {
    $title = htmlspecialchars($this->getValue('name'));
}

@schuer
Copy link
Member

schuer commented Aug 17, 2017

Wurde gefixt mit #55

@schuer schuer closed this as completed Aug 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants