Playing with FrogCMS (Part 4: The Theme [continued...])

We got that theme up and running pretty quickly. So far so good. Now I’d like to take it just a little bit further and see how flexible we can make things.

Adding a dynamic ID and class to the body

Here you can find a list FrogCMS functions. There should be something here that will allow me to dynamically add a relevant ID and class to the body tag of everypage. I decided to go with this function:

echo $this->slug();

The slug is basically the readable URL (so the page title separated by dashes and cleansed of special characters). So I altered to body tag in my layout to look like this:

<body id="page-<?php echo $this->slug(); ?>" class="">

Now if we move to our test page…

We can take a look at Firebug and see that our body has the ID page-test.

This is perfect but if we look at the homepage we’ll see that the body ID is page-. The homepage does not have a slug. I’m going to get around this with a quick and dirty conditional.

    <?php
	if ($this->slug() == '')
	{
	   $body_id = 'home';
	}
	else
	{
	   $body_id = $this->slug();
	}
     ?>
 
<body id="page-<?php echo $body_id; ?>" class="">

Ok, that works. Will backfire on me down the road? Probably, but for now it works fine.

Adding metadata

Let’s make sure any keywords or descriptions we add the the metadata of a page actually render out on that page. This is basically straight out of the FrogCMS docs. Just paste this into the head of the page:

  <meta name="keywords" content="<?php echo $this->keywords(); ?>" />
  <meta name="description" content="<?php echo $this->description(); ?>" />

Make sure to enter the keywords and description.

Taco, fettuccine, linguine, martini, bikini… keyword and description meta data in perfect cursive…

Page headers

I’m going to quickly make a change to display the page title as a H2 on everypage. In the layout I replace this:

<h3>What’s new at the Gong Shop?</h3>

with this:

<h3><?php echo $this->title(); ?></h3>

Alright, I’m kind of sick of this now. I’m going to finish a few things off and set up the site with only the pages shown in my comp. Next we’ll see about the blog section.

Next: Playing with FrogCMS (Part 5: The Blog)


No Comments »

No comments yet.

Leave a comment