From d7af491a81f192105fa5ee45cc9e7623156a3b94 Mon Sep 17 00:00:00 2001 From: HWFord Date: Wed, 6 Apr 2022 09:51:08 +0200 Subject: [PATCH] Fixes #1625 adds class to body Adds class to body, get id for category tag or picture, add dynamic class to body using id Also used on page where albums and tags are combined TODO make compatible with modus --- include/page_header.php | 4 ++++ index.php | 22 +++++++++++++++++++++- picture.php | 6 ++++++ themes/default/template/header.tpl | 2 +- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/include/page_header.php b/include/page_header.php index f39ee9b20..cd314ccd4 100644 --- a/include/page_header.php +++ b/include/page_header.php @@ -47,6 +47,10 @@ $template->assign( 'LEVEL_SEPARATOR' => $conf['level_separator'], 'SHOW_MOBILE_APP_BANNER' => $show_mobile_app_banner, + + 'BODY_CLASS' => + isset($page['body_class']) ? + $page['body_class'] : '', )); diff --git a/index.php b/index.php index ee2c73554..28f93c572 100644 --- a/index.php +++ b/index.php @@ -111,7 +111,27 @@ if ( empty($page['is_external']) ) { //----------------------------------------------------- template initialization $page['body_id'] = 'theCategoryPage'; - + + if ('categories' == $page['section'] && isset($page['category'])) + { + $page['body_class'] = 'category_'.$page['category']['id']; + if (isset($page['combined_categories'])) + { + foreach ($page['combined_categories'] as $combined_categories) + { + $page['body_class'] .= '_'.$combined_categories['id']; + } + } + } + elseif (isset($page['tags'])) + { + $page['body_class'] = 'tag'; + foreach ($page['tags'] as $tag) + { + $page['body_class'] .= '_'.$tag['id']; + } + } + if (isset($page['flat']) or isset($page['chronology_field'])) { $template->assign( diff --git a/picture.php b/picture.php index 7cebc101d..ef7a4bc67 100644 --- a/picture.php +++ b/picture.php @@ -627,6 +627,12 @@ if ( $metadata_showable and pwg_get_session_var('show_metadata') ) $page['body_id'] = 'thePicturePage'; +if (isset($page['image_id'])) +{ + $page['body_class'] = 'image_'.$page['image_id']; +} + + // allow plugins to change what we computed before passing data to template $picture = trigger_change('picture_pictures_data', $picture); diff --git a/themes/default/template/header.tpl b/themes/default/template/header.tpl index 5092b3814..823dc7a60 100644 --- a/themes/default/template/header.tpl +++ b/themes/default/template/header.tpl @@ -68,7 +68,7 @@ {/if} - +