matthijs110 Posted August 8, 2014 Share Posted August 8, 2014 Hello, I've made a function that contains the html header (<head>). When I call that function in a other file, with the header file included, it puts the header function in the body. So all the meta tags are in the body, instead of the head. Would it be possible to load this all in the head? The head function does contain the html and head tags. However, without them, it still doesn't want to go to the head. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted August 8, 2014 Share Posted August 8, 2014 Can you show us this call? That would be so much easier to debug than taking a flying leap at whatever you are talking about. Quote Link to comment Share on other sites More sharing options...
matthijs110 Posted August 8, 2014 Author Share Posted August 8, 2014 Can you show us this call? That would be so much easier to debug than taking a flying leap at whatever you are talking about. Sure, LayoutController.php: function head(){ ?> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta name="author" content="matthijs110"> <link href='//fonts.googleapis.com/css?family=Ubuntu:300,400,500,700,300italic,400italic,500italic,700italic' rel='stylesheet' type='text/css'> <link href='//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'> <!-- Bootstrap core CSS --> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <!-- FontAwesome Icons --> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css"> <!-- Bootstrap Core JS --> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> <meta name="apple-mobile-web-app-title" content="Panel"> <meta name="apple-mobile-web-app-capable" content="yes"> </head> </html> <?php } ?> And in my profile.php: <head> <?php require_once('Code/Controllers/LayoutController.php'); head(); ?> </head> Quote Link to comment Share on other sites More sharing options...
ginerjm Posted August 8, 2014 Share Posted August 8, 2014 Let's see. You have a head tag, then you include some code, then you call a function from that include which re-issues a head tag, close the head, and then you issue a second end head tag. AND you open and close your html inside of the header section. I would think that any browser would have a huge problem handling this mess. BTW - why a function? You're including static html code - why make it a php function? Quote Link to comment Share on other sites More sharing options...
CroNiX Posted August 8, 2014 Share Posted August 8, 2014 (edited) head() should be more like <html> <head> ...head code </head> <body> (no closing html!!!) Then create a foot(), which would be something like </body> </html> Then profile would sandwich the actual content between the head() and foot(), like: <?php require_once('Code/Controllers/LayoutController.php'); head(); //create the header ?> <div>This is the profile page</div> //insert the page code in the body <?php foot(); //create the footer which closes the body/html to complete the page ?> Edited August 8, 2014 by CroNiX Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted August 8, 2014 Share Posted August 8, 2014 I think there's a deeper problem: You've started to implement your own template system which appearently isn't up to the job and may never be. Why not use an existing template engine which actually works? There's Twig, there's Smarty, and there are many others. I'm sure you'll find one that you like. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.