$view = View::factory('template');
$view->title = 'My title';
$view->description = 'An example of my template view.';
$view->keywords = 'example,view,template';
$view->css = array(
    'normal'    => 'style.css',
    'IE'        => 'ie.css',
);
$view->js = array(
    'normal' => 'spark.js',
    'normal' => 'jquery.js',
);
$this->request->response = $view->render();
html
<!DOCTYPE html>
<html lang="en">
    <head>
        <title><?php if(isset($title)) ? echo $title : echo 'Untitled' ?></title>
        <meta name='description' content='<?php if(isset($description)) ? echo $description : echo 'No description' ?>' />
        <meta name='keywords' content='<?php if(isset($keywords)) ? echo $keywords: echo 'No keywords' ?>' />
        <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
        <?php
            if(isset($css)) :
            foreach($css as $type => $file) :
            if($type != 'normal') echo '<!--[if ' . $type . ']>';
        ?>
        <link type='text/css' href='<?php echo $file ?>' rel='stylesheet' />
        <?php
            if($type != 'normal' echo '<![endif]-->');
            endforeach;
            endif;
        ?>
        <?php
            if(isset($js)) :
            foreach($js as $type => $file) :
            if($type != 'normal') echo '<!--[if ' . $type . ']>';
        ?>
        <script type='text/javascript' src='<?php echo $file ?>'></script>
        <?php
            if($type != 'normal' echo '<![endif]-->');
            endforeach;
            endif;
        ?>
    </head>
   
    <body>
       
    </body>
</html>
           
          
A Kohana view template
Posted by
anonymous
on Tuesday, November 16, 2010
Labels:
kohana 3,
kohana 3 views,
kohana framework
1 comments:
well, nice code.
Post a Comment