Scripts for Pulse

Hi! At Pulse Style we create all sorts of fun stuff for the very talented CMS, Pulse.

Pulse Script icon

Body Class

version 1.2

Body Class is a PHP script to add class styles to the body tag of your page based on the current page state. It is based on the same principles as the WordPress body class but has been created specifically for Pulse. It easily allows you to target and style specific pages or blog posts within the CMS.

What does the script do?

The script will output class styles to the page based on the environment the page is viewed in.
At present the script will add the following class styles to the page;

  • The page name/slug - home for example
  • The page type - page, blog, blog-home, single-post
  • The blog post ID - postid-3
  • The blog post date - day-10, month-5, year-2016
  • Is the admin logged in? - logged-in
  • Is this the 404 page? - error404
  • The current page template - page-template-default

Below is an example showing the class styles for a page after the script has been applied to the Pulse template.

<body class="work page logged-in page-template-default">

With these styles applied to the body tag it is very easy to style your Pulse site depending on where the user is and what sort of page they are looking at. You could, for example, style the page differently if the admin is currently logged into Pulse or adjust the layout of the template specifically for single posts.

For example;

body.logged-in { outline:1px solid #f00 }

Installing the script

Download the PHP script and FTP the file into your Pulse install at inc > tags.
Open up your template and add the following code to the top of the file (anywhere before the body tag will do).

<?php include_once("inc/tags/body-class.php"); ?>

Lastly locate the body tag in your template and edit it so it looks like the one below;

<body<?php body_class(''); ?>>

Script options

The body_class function accepts two parameters;

  1. extra-classes - add any extra classes to the body tag by simply adding them here.
  2. raw - if you just want the class names output without the class="" then append true as a second parameter to the function.

<body class="<?php body_class('foo bar baz',true); ?>">

Body Class

Version 1.2
Requires Pulse 4.0 or above
Last Updated 4th November 2016

What is Pulse?

Pulse is a simple, yet powerful content management system and is ideally suited to small or medium sized web sites.

We've developed a number of plug-ins, themes and galleries for Pulse to allow you and your clients to add rich content to your sites quickly and easily.

About Pulse Style

Pulse Style is run by Tim Plumb who has been using Pulse for both personal and commercial projects since 2012. Over that time he's created a number of plug-ins, themes, custom galleries and other scripts for the CMS.

Tim can also be found over at Plumb Design, or making cool stuff for Freeway Pro over at Freeway Style and Freeway Actions. Pop by and say hi!

Sign up for news and offers

Stay in touch by signing up for our (infrequent) email newsletter with details on what's new from Pulse Style.