Improving the body classes in X-Cart 4
To get better granularity with styling in CSS on X-Cart 4 I have always felt that the body tag could do with more class declarations a bit like WordPress and Drupal.
So this could be used for example for styling just category pages or specific products and categories.
To do this in X-Cart 4 you need to download and edit the include/func/func.core.php file.
Find the lines
1 2 3 4 5 6 7 8 9 10 11 |
global $container_classes; // Admin preview if ( isset($_GET['is_admin_preview']) && $_GET['is_admin_preview'] == 'Y' ) { $templater->assign('is_admin_preview', true); $container_classes[] = "admin-preview"; } |
and change this to
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
global $container_classes; <span style="color: #008000;"> #set body classes if ($templater->_tpl_vars['main']) { $container_classes[] = "page-type-".$templater->_tpl_vars['main']; } if ($templater->_tpl_vars['main'] == "catalog") { if($templater->_tpl_vars['cat']) { $container_classes[] = "catalog-internal"; $container_classes[] = "catalog-catid-".$templater->_tpl_vars['cat']; } else { $container_classes[] = "homepage"; $container_classes[] = "catalog-catid-0"; } }</span> // Admin preview if ( isset($_GET['is_admin_preview']) && $_GET['is_admin_preview'] == 'Y' ) { $templater->assign('is_admin_preview', true); $container_classes[] = "admin-preview"; } |
You will then see the following classes appear in the source code:
Homepage
1 |
<<span class="start-tag">body</span> <span class="attribute-name">class</span>="<a class="attribute-value">fancycat-page-skin-icons fancycat-page-subskin-c page-type-catalog homepage catalog-catid-0 </a>"> |
1 |
<<span class="start-tag">body</span> <span class="attribute-name">class</span>="<a class="attribute-value">fancycat-page-skin-icons fancycat-page-subskin-c page-type-catalog catalog-internal catalog-catid-168 </a>"> |
1 |
<<span class="start-tag">body</span> <span class="attribute-name">class</span>="<a class="attribute-value">fancycat-page-skin-icons fancycat-page-subskin-c page-type-product </a>"> |
1 |
<<span class="start-tag">body</span> <span class="attribute-name">class</span>="<a class="attribute-value">fancycat-page-skin-icons fancycat-page-subskin-c page-type-pages </a>"> |