Last active
March 30, 2019 17:16
-
-
Save robwent/f72c687e29d95137b0acf8436abf64de to your computer and use it in GitHub Desktop.
Adds Joomla article alternative layout information as a class to the body tag. Use in your templates index.php file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$app = JFactory::getApplication(); | |
$view = $app->input->getCmd( 'view', '' ); | |
$body_class = ''; | |
if ( $view === 'article' ) { | |
$article = JTable::getInstance( "content" ); | |
$id = $app->input->getInt( 'id' ); | |
$article->load( $id ); | |
$attribs = json_decode( $article->attribs ); | |
if ( property_exists( $attribs, 'article_layout' ) ) { | |
$article_layout = str_replace( ':', '-', $attribs->article_layout ); | |
$body_class .= ' article-layout-' . $article_layout; | |
} | |
} | |
?> | |
<body class="<?php echo $body_class; ?>"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment