diff --git a/include/common.inc.php b/include/common.inc.php index c2967d4c1..47d32f160 100644 --- a/include/common.inc.php +++ b/include/common.inc.php @@ -51,6 +51,7 @@ $page = array( 'errors' => array(), 'warnings' => array(), 'messages' => array(), + 'body_classes' => array(), ); $user = array(); $lang = array(); diff --git a/include/page_header.php b/include/page_header.php index cd314ccd4..428442fab 100644 --- a/include/page_header.php +++ b/include/page_header.php @@ -48,10 +48,11 @@ $template->assign( 'SHOW_MOBILE_APP_BANNER' => $show_mobile_app_banner, - 'BODY_CLASS' => - isset($page['body_class']) ? - $page['body_class'] : '', - )); + 'BODY_CLASSES' => $page['body_classes'], + + 'BODY_DATA' => json_encode($page['body_classes']), + ) +); // Header notes diff --git a/include/section_init.inc.php b/include/section_init.inc.php index 60f439268..94f7d7d74 100644 --- a/include/section_init.inc.php +++ b/include/section_init.inc.php @@ -647,6 +647,42 @@ if ( 'categories'==$page['section'] and isset($page['category']) and !isset($pag } unset( $need_redirect, $page['hit_by'] ); } +echo('
');print_r($page);echo('');
+array_push($page['body_classes'], 'section-'.$page['section']);
+
+if ('categories' == $page['section'] && isset($page['category']))
+{
+ $body_class = 'category-'.$page['category']['id'];
+ if (isset($page['combined_categories']))
+ {
+ foreach ($page['combined_categories'] as $combined_categories)
+ {
+ $body_class .= '-'.$combined_categories['id'];
+ }
+ }
+ array_push($page['body_classes'], $body_class);
+}
+elseif (isset($page['tags']))
+{
+ $body_class = 'tag';
+ foreach ($page['tags'] as $tag)
+ {
+ $body_class .= '-'.$tag['id'];
+ }
+ array_push($page['body_classes'], $body_class);
+
+}
+elseif (isset($page['search']))
+{
+ array_push($page['body_classes'], 'search-'.$page['search']);
+}
+
+if (isset($page['image_id']))
+{
+ array_push($page['body_classes'], 'image-'.$page['image_id']);
+}
+
+
trigger_notify('loc_end_section_init');
?>
\ No newline at end of file
diff --git a/index.php b/index.php
index 28f93c572..84a378937 100644
--- a/index.php
+++ b/index.php
@@ -112,26 +112,6 @@ 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 ef7a4bc67..7cebc101d 100644
--- a/picture.php
+++ b/picture.php
@@ -627,12 +627,6 @@ 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 823dc7a60..a3ecc479c 100644
--- a/themes/default/template/header.tpl
+++ b/themes/default/template/header.tpl
@@ -68,7 +68,7 @@
{/if}
-
+