html - php template add dynamic js and css -
html - php template add dynamic js and css -
i design php products page template :
index:
<!doctype html> <html> <head> <link href="/user/admin/templates/css/bootstrap.min.css" rel="stylesheet"> <script src="/user/admin/templates/js/jquery-1.10.1.min.js"></script> </head> <body> <?php include ('dynamicpage.php'); //load dynamic page request example: adduser.php ?> </body> </html>
i need add together .js
, .css
file in each dynamicpage.php
this:
adduser.php :
<link href="/user/admin/templates/css/formvalidation.min.css" rel="stylesheet"> <script src="/user/admin/templates/js/formvalidation.min.js"></script> <?php // code + html ?>
addpage.php :
<link href="/user/admin/templates/css/select2.min.css" rel="stylesheet"> <script src="/user/admin/templates/js/select2.min.js"></script> <?php // code + html ?>
now, need print daynamic .js
, .css
dynamic page top of page <head></head>
this:
if load addpage.php head template :
<link href="/user/admin/templates/css/bootstrap.min.css" rel="stylesheet"> <script src="/user/admin/templates/js/jquery-1.10.1.min.js"></script> <link href="/user/admin/templates/css/select2.min.css" rel="stylesheet"> <script src="/user/admin/templates/js/select2.min.js"></script>
if load adduser.php head template :
<link href="/user/admin/templates/css/bootstrap.min.css" rel="stylesheet"> <script src="/user/admin/templates/js/jquery-1.10.1.min.js"></script> <link href="/user/admin/templates/css/formvalidation.min.css" rel="stylesheet"> <script src="/user/admin/templates/js/formvalidation.min.js"></script>
how print .js
, .css
using php function or class?! sorry im new user of php
, not have idea.
it not possible way have setup, instead set contents of dynamicpage.php
variable , utilize variable in body. if setup other variables additional css , js files, utilize too.
contents of dynamicpage.php
this:
$css = "dynamicpage.css"; $js = "dynamicpage,js"; $content = "<div>blabla</div>";
your index file this:
<?php include ('dynamicpage.php'); ?> <!doctype html> <html> <head> <link href="/user/admin/templates/css/bootstrap.min.css" rel="stylesheet"> <script src="/user/admin/templates/js/jquery-1.10.1.min.js"></script> <link href="/user/admin/templates/css/<?php echo $css; ?>" rel="stylesheet"> <script src="/user/admin/templates/js/<?php echo $js; ?>"></script> </head> <body> <?php echo $content; ?> </body> </html>
php html template-engine
Comments
Post a Comment