FIX articoli senza body
This commit is contained in:
parent
a1616ea461
commit
13822ec957
1 changed files with 8 additions and 2 deletions
|
@ -34,9 +34,15 @@ class CalendarRorController extends ControllerBase {
|
||||||
$nodes_e = \Drupal\node\Entity\Node::loadMultiple($nids);
|
$nodes_e = \Drupal\node\Entity\Node::loadMultiple($nids);
|
||||||
$data['nodes'] = array();
|
$data['nodes'] = array();
|
||||||
foreach($nodes_e as $nid => $node) {
|
foreach($nodes_e as $nid => $node) {
|
||||||
$data['nodes'][$nid] = $node->toArray();
|
$na = $node->toArray();
|
||||||
|
if(count($na['body']) > 0) { // c'e' gente che pubblica articoli senza body
|
||||||
|
$body = $na['body'][0]['value'];
|
||||||
|
} else {
|
||||||
|
$body = '';
|
||||||
|
}
|
||||||
|
$data['nodes'][$nid] = $na;
|
||||||
$data['nodes'][$nid]['summary'] = htmlspecialchars(substr(
|
$data['nodes'][$nid]['summary'] = htmlspecialchars(substr(
|
||||||
html_entity_decode(strip_tags($data['nodes'][$nid]['body'][0]['value'])),
|
html_entity_decode(strip_tags($body)),
|
||||||
0, 3500), ENT_XML1, 'UTF-8');
|
0, 3500), ENT_XML1, 'UTF-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue