jeudi 21 mai 2015

Include depending on body class

I'm trying to figure out how to check for a single class on the body tag then include a file.

My header.php contains:

</head>
<?php $class = BODY_CLASS; ?>
<body class="<?php echo $class; ?>" id="top">

And in the body:

<?php if (isset($class) && $class == 'work') { ?>
    <?php include( $_SERVER['DOCUMENT_ROOT'] . MODULES . "_social.php"); ?>
<?php }; ?>

This works fine so long as I only have a single class on the body tag, but what if I have multiple tags?

for instance my body tag outputs this:

<body id="top" class="work project1">

How can I check for the work even if other classes exist?

Aucun commentaire:

Enregistrer un commentaire