Skip to content

Commit

Permalink
Make title_format work with selects for places with old storage layer.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobdenotter committed Oct 10, 2017
1 parent c936ca8 commit a490b4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/view/twig/_macro/_macro.twig
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#}
{% macro contentlink(contenttype, content) %}
{% import _self as crosslinks %}
{% set title = content.getTitle(true) %}
{% set title = content.getTitle() %}
{{ crosslinks.contentlink_by_id(contenttype, title, content.id) }}
{% endmacro %}

Expand Down
12 changes: 5 additions & 7 deletions src/Storage/Entity/ContentValuesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,10 @@ public function getTitle($allowBasicTags = false)
}

foreach ($this->getTitleColumnName() as $fieldName) {
if (strip_tags($this->values[$fieldName], $allowedTags) !== '') {
$titleParts[] = strip_tags($this->values[$fieldName], $allowedTags);
// Make sure we add strings only, as some fields may be an array or DateTime.
$value = is_array($this->values[$fieldName]) ? implode(' ', $this->values[$fieldName]) : (string) $this->values[$fieldName];
if (strip_tags($value, $allowedTags) !== '') {
$titleParts[] = strip_tags($value, $allowedTags);
}
}

Expand All @@ -616,11 +618,7 @@ public function getTitleColumnName()
{
// If we specified a specific fieldname or array of fieldnames as 'title'.
if (!empty($this->contenttype['title_format'])) {
if (!is_array($this->contenttype['title_format'])) {
$this->contenttype['title_format'] = [$this->contenttype['title_format']];
}

return $this->contenttype['title_format'];
return (array) $this->contenttype['title_format'];
}

// Sets the names of some 'common' names for the 'title' column.
Expand Down

0 comments on commit a490b4b

Please sign in to comment.