Skip to content

Commit e73b3c9

Browse files
committed
FAXE-381 set last update date
1 parent 1e8729a commit e73b3c9

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

web/themes/custom/fds_faxe_theme/fds_faxe_theme.theme

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,26 @@ use Drupal\node\Entity\Node;
88
use Drupal\taxonomy\Entity\Term;
99

1010

11+
/**
12+
* Implements hook_theme_suggestions_page().
13+
*/
14+
function fds_faxe_theme_theme_suggestions_block_alter(array &$suggestions, array $variables) {
15+
if ($variables['elements']['#id'] == 'lastupdated') {
16+
if (file_exists(__DIR__ . '/templates/block/block--lastupdated.html.twig')) {
17+
$suggestions = ["block__lastupdated"];
18+
}
19+
}
20+
}
21+
22+
23+
24+
1125
/**
1226
* Implements hook_preprocess_block().
1327
*/
1428
function fds_faxe_theme_preprocess_block(&$variables) {
15-
if ($variables['elements']['#id'] == 'fds_faxe_theme_indholdfield') {
29+
30+
if ($variables['elements']['#id'] == 'fds_faxe_theme_indholdfield') {
1631
$node = $variables['content']['field']['#object'];
1732
$ext_links = $node->get('field_ext_links')->getValue();
1833
foreach( $ext_links as $ext_link) {
@@ -21,6 +36,14 @@ function fds_faxe_theme_preprocess_block(&$variables) {
2136
$variables['content']['field'][] = $link->toRenderable();
2237
}
2338
}
39+
40+
if ($variables['elements']['#id'] == 'lastupdated') {
41+
$node = \Drupal::routeMatch()->getParameter('node');
42+
if (!empty($node->getType()) && $node->getType() == 'os2web_page') {
43+
$variables['lastupdated'] = strftime("%d.%m.%Y", $node->getChangedTime());
44+
}
45+
}
46+
2447
}
2548

2649
/**
@@ -31,6 +54,7 @@ function fds_faxe_theme_preprocess_page(array &$variables) {
3154
$variables['theme_settings']['footer']['footer_show_latest_content'] = theme_get_setting('footer_show_latest_content');
3255
$variables['theme_settings']['branding']['branding_toggle'] = theme_get_setting('branding_toggle');
3356
$variables['theme_settings']['branding']['branding_text'] = theme_get_setting('branding_text');
57+
$variables['lastupdated'] = time();
3458
}
3559

3660
/**
@@ -206,6 +230,12 @@ function fds_faxe_theme_preprocess_node(array &$variables) {
206230
$variables['content']['field_os2web_event_end_date'][0]['#text'] = 'til ' . $newEndDate;
207231
}
208232
}
233+
234+
// if ($node->getType() == 'os2web_page') {
235+
$variables['#lastupdated'] = time();
236+
// }
237+
238+
209239
}
210240

211241
/**

0 commit comments

Comments
 (0)