Welcome Guest, Not a member yet? Register   Sign In
scripts stylesheets
#1
Thumbs Up 

Is it a bad practice to make a header and footer file and call EVERY script and style sheet inside ?
Reply
#2

@ChiKaLiO,

Its only bad practice if your not using EVERY script and style sheet for every page. You can create a standard header and footer and if necessary give them the capability to add additional script and style sheets.
Reply
#3

(03-10-2019, 09:41 PM)php_rocs Wrote: @ChiKaLiO,

Its only bad practice if your not using EVERY script and style sheet for every page.  You can create a standard header and footer and if necessary give them the capability to add additional script and style sheets.

y thats exactly what made me think lol so for "special" scripts/stylesheets i just add them to the body or there is a better way to do it ?
Reply
#4

(This post was last modified: 03-11-2019, 12:55 AM by John_Betong.)

(03-10-2019, 06:51 PM)ChiKaLiO Wrote: Is it a bad practice to make a header and footer file and call EVERY script and style sheet inside ?

For simple sites I have recently started to generate web-pages by using a common master View template which caters for the vast majority of cases:

Parameters passed to the common template are all generated in Controllers and passed to the following View:
PHP Code:
<?php 
  declare
(strict_types=1);

$title    $title    ?? "John_Betong's LoRaWAN SVG Charts"    
$desc     
$desc     ?? $title    
$jsScript 
$jsScript ?? '';
$xStyle   $xStyle   ?? '';
$subs     $subs     ?? '';
$more     $more     ?? '';

$tmp = <<< ____TMP
<!DOCTYPE HTML>
<html lang='en'>
<head>
<title> 
$title </title>
<meta charset="utf-8">
<meta name="description" content="
$desc" />
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">
<link rel="canonical" href="
$canon">

  
$jsScript

<style> 
$styleTtn </style>
</head>
<body> 

  
$menuTtn

  <div class="w88 mgt bge">
    
$page
    
$subs 
    
$more
  </div>  

  
$footer 

</body>
</html>

____TMP;

echo 
$tmp
Reply
#5

@ChiKaLiO,

Another approach is you could create a master header and footer view that has all styles and scripts which can be turned on or off by the value settings of an array. i.e. $data[viewheader] =[0,1,0,1] //[custom-scipt,jquery-js,custom-css,jquery-css]
Reply
#6

Best community ever! thank you guys <3
Reply




Theme © iAndrew 2016 - Forum software by © MyBB