1
This question is very large and can be answered multiple times but I did not get answers in a discussion forum. I would like to know how to build the following page using PHP (but I built using html):
it has the following HTML code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Titulo</title>
<script type="text/javascript" src="../Bootstrap/js/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" src="../Bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../datepicker/js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="../Jquery-Validate/jquery.validate.min.js"></script>
<script type="text/javascript" src="../Javascript/ActionsJS.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="../Bootstrap/css/bootstrap.min.css" media="screen" />
<link rel="stylesheet" type="text/css" href="../datepicker/css/datepicker.css" media="screen" />
<link rel="stylesheet" type="text/css" href="../CSS/StyleSheet.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation"><!--------- START Navbar --------->
<div class="container">
<div class="navbar-header"><!-- START Brand and toggle get grouped for better mobile display -->
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Meu Site</a>
</div><!-- END Brand and toggle get grouped for better mobile display -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"><!-- START Collect the nav links, forms, and other content for toggling -->
<ul class="nav navbar-nav navbar-right">
<li><button type="button" class="btn btn-info navbar-btn" data-toggle="modal" data-target="#login_modal">Login</button></li>
<li><button type="button" class="btn btn-info navbar-btn" data-toggle="modal" data-target="#create_account_modal">Create Account</button></li>
</ul>
<form class="navbar-form span7 text-center" role="search" id="search-form" action="../action.php" method="get">
<div class="input-group">
<input class="form-control" type="text" id="search_input" name="search_input" placeholder="Search" />
<div class="input-group-btn">
<button class="btn btn-default" type="submit" name="search_form_submit" value="search">Search</button>
</div>
</div>
</form>
</div><!-- END Collect the nav links, forms, and other content for toggling -->
</div>
</nav><!--------- END Navbar --------->
<div class="wrapper" role="main"><!-- START Content -->
<div class="container"><!-- START Related Tags -->
<div class="row">
<div id="right_sidebar" class="col-md-2 pull-right"><!-- START Right Sidebar -->
<div class="row">
<h4>Duraçao</h4>
<div class="radio">
<label><input type="radio" name="duratrion" value="dur-0" checked="checked">Indeterminado</label>
</div>
<div class="radio">
<label><input type="radio" name="duratrion" value="dur-1">1 Dia</label>
</div>
<div class="radio">
<label><input type="radio" name="duratrion" value="dur-2">3 Dias</label>
</div>
<div class="radio">
<label><input type="radio" name="duratrion" value="dur-3">5 Dias</label>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
so that I can exchange these small elements among others pages (.php) see my rudimentary example: I created this header.php file (which renders navbar in red)
<?php
echo'
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Titulo</title>
<script type="text/javascript" src="../Bootstrap/js/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" src="../Bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../datepicker/js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="../Jquery-Validate/jquery.validate.min.js"></script>
<script type="text/javascript" src="../Javascript/ActionsJS.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="../Bootstrap/css/bootstrap.min.css" media="screen" />
<link rel="stylesheet" type="text/css" href="../datepicker/css/datepicker.css" media="screen" />
<link rel="stylesheet" type="text/css" href="../CSS/StyleSheet.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation"><!--------- START Navbar --------->
<div class="container">
<div class="navbar-header"><!-- START Brand and toggle get grouped for better mobile display -->
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Meu Site</a>
</div><!-- END Brand and toggle get grouped for better mobile display -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"><!-- START Collect the nav links, forms, and other content for toggling -->
<ul class="nav navbar-nav navbar-right">
<li><button type="button" class="btn btn-info navbar-btn" data-toggle="modal" data-target="#login_modal">Login</button></li>
<li><button type="button" class="btn btn-info navbar-btn" data-toggle="modal" data-target="#create_account_modal">Create Account</button></li>
</ul>
<form class="navbar-form span7 text-center" role="search" id="search-form" action="../action.php" method="get">
<div class="input-group">
<input class="form-control" type="text" id="search_input" name="search_input" placeholder="Search" />
<div class="input-group-btn">
<button class="btn btn-default" type="submit" name="search_form_submit" value="search">Search</button>
</div>
</div>
</form>
</div><!-- END Collect the nav links, forms, and other content for toggling -->
</div>
</nav><!--------- END Navbar --------->
</body>
</html>
';
?>
I think this is not the best way and I would like to know what would be a suitable way, where I could call these little ones. php (containing the navbar "red" the sidebar in "green") and build a single page still have other points that would be 1º the fact that I’m replicating the tag in the pages header.php and sidebar.php how could I be more efficient in this appecto? 2º the content of the tag is different between each page 3º in case of user login how would change the Login and Create Account buttons in . php to a logout button?
you put "render html with php", but this is not the problem, because in a way they are linked and who renders is the client-side, could explain what the goal, preferably write for "topics" (more organized), thanks.
– Guilherme Nascimento
@Guilhermenascimento the goal is to break the HTML (which generates the image) into small codes phps. so that it is possible to mount a code . php that imports for example a.php sidebar.php header, .php form and create a single page with these parts
– Ricardo
you made that clear in the commentary, but I had not understood it in the question, for the title leads to understand something else. Writing by topics helps :) But I did understand what you need, in my opinion it is something that can actually get several different answers, but it is not an invalid question. As for your code me personally (my opinion only) I think that if it’s about organization, you should seriously think about a system of Template and maybe a MVC.
– Guilherme Nascimento
posted an example in . php where the header is generated by arquvio . php as I would to "link" this header to a file . php that generates the footer for example?
– Ricardo