php - Include a js and css file only in a specific view -
php - Include a js and css file only in a specific view -
in codeigniter application have mutual header , footer view, include in different views. header_view
simple as:
<!doctype html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title><?php echo $page_title;?></title> <link rel="stylesheet" href="<?php echo base_url();?>/css/master.css" type="text/css" media="screen" /> <script src="<?php echo base_url();?>js/common.js" type="text/javascript"></script> </head> <body> <!-- end of header -->
now lets suppose have view called form_view
, include css file form.css
, javascript file form.js
. since these files used in form_view, don't want add together them in header_view, because included in of views in application.
so question remains, how can include specific css or specific javascript file on specific view, when using mutual header above.
thanks.
you write zend_bootstrap , run before views. bootstrap file responsible setting css , js files header grab them array.
bootstrap:
$head_array = array( 'css' => array( '/static/css/style.css', '/static/css/style1.css' ), 'js' => array( '/static/js/script.js' ) ) if($view == 'view_form') { $head_array['css'][] = '/static/css/form.css'; }
of course of study illustration primitive shows idea.
php codeigniter templates php-include
Comments
Post a Comment