scotch-io / stencil

Stencil is an awesome and simple templating engine for Codeigniter.
Other
46 stars 24 forks source link

add body class functionality #2

Closed whatnickcodes closed 11 years ago

whatnickcodes commented 11 years ago
$this->data['body_class'] = $this->CI->router->fetch_class().' '.$this->CI->router->fetch_class().'-'.$this->CI->router->fetch_method();

Add this to paint() function in libary/Stencil.php

Note: This makes $body_class now a reserved variable name in views

whatnickcodes commented 11 years ago

NOTE:

<?php

class Example extends CI_Controller {

     function index() {
          $this->stencil->paint('example_view');
     }

}

/example and /example/index will yield this:

<body class="example example-index">

But this "/example/8349023849023849032" will yield this:

<body class="example example-8349023849023849032">

example-index won't exist

Obviously -- 8349023849023849032 is not a function name, but a URI segment just appended to the URL. So it should be noted somewhere in the docs that this isn't technically a bullet proof method

chris-sev commented 11 years ago

When it does a 404 error, the body class is "pages pages-index".

How do you want to fix that? We could have 404 be its own controller or method.