Solved

php website basics

Posted on 2011-09-18
6
376 Views
Last Modified: 2012-06-27
I have website with 5 pages pure HTML at this moment, but I will need to add 20 more pages soon and it becomes quite difficult to maintain.
I got an idea to use php, I need to change some meta tags and entry of page.
How can I do this? With include function?
Here is example:

<head>
<title>XXXXXXXXXXXXXXXX</title>
<meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org" />
<meta name="keywords" content="XXXXXXXXXXXXXXXXXXXXXXXX" />
<meta name="description" content="XXXXXXXXXXXXXXXXXXXXX" />

<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="cache-control" content="Public" />
<link href="bagachst.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="/favicon.ico" />
</head>
<body>

<div id="wrapper" >
<div id="header">
<div id="logo">
<p>xxxxxxxxxxx</p>
</div>
<div id="menu">
<ul>
<li><a href="index.html">xxxxx</a></li>
<li><a href="about.html">xxxxx</a></li>
<li><a href="gallery.html">xxxxx</a></li>
<li><a href="prices.html">xxxxx</a></li>
<li><a href="contact.html">xxxxx</a></li>
</ul>
</div>
</div>
<div id="page">
<div class="post" id="content">
<h1 class="title">xxxxxxxxxx</h1>
<p class="meta"></p>
<div class="entry">
<p>
xxxxxxxxxxxxxxxxxxxxxxxxxx - 25 xxxxxxxxxxxxxxxxxx</p>
 
<p>xxxxxxxxxxxxxx-1 xxx-15 xxxxxxxx (xxxxxxxxxxxx 10 xxxxxxxxx)</p>
<p>xxxxx xxxxx 3 xxxxxxxx xxxxx xxxxxxxx, 3-15 x xx 10 x x.</p>
 
<p>xxxxxxxxxxxxxx xxxxxxxxxxxxx xxxxxxxx:<br />
<ul>
<li>xxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxx</li>
<li>xxxxxxx</li>
<li>xxxxxxxxxxxxxxxxx xxxxxxxx</li>
<li>xxxxxxx</li>
<li>xxxxxxxxxxxxxxxxxxxx</li>
</ul>
</p>

</div>
</div>
</div>
</div>
<div id="bgbottom" >
<div id="footer" >
<p>Copyright © 2010-2011.</p>
</div></div>

<div id="bglayout" ><div id="bgtop" ><div id="bgmenu" ><div class="left" ></div><div class="right" ></div></div></div></div>

</body>
</html>

I need to change only bold parts.

Any help please.
0
Comment
Question by:SSupreme
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 10

Accepted Solution

by:
acbxyz earned 500 total points
ID: 36557438
You can use a file template.php for main layout and other files, which contain content.
template.php
<?php
if (empty($head_title)) $head_title = 'no title defined';
// you can do this for all (optional) variables to suppress errors or warnings.
?>
<head>
<title><?php echo $head_title; ?></title>
<meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org" />
<meta name="keywords" content="<?php echo $head_keywords; ?>" />
<meta name="description" content="<?php echo $head_description; ?>" />
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="cache-control" content="Public" />
<link href="bagachst.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="/favicon.ico" />
</head>
<body>

<div id="wrapper" >
<div id="header">
<div id="logo">
<p>xxxxxxxxxxx</p>
</div>
<div id="menu">
<ul>
<li><a href="index.html">xxxxx</a></li>
<li><a href="about.html">xxxxx</a></li>
<li><a href="gallery.html">xxxxx</a></li>
<li><a href="prices.html">xxxxx</a></li>
<li><a href="contact.html">xxxxx</a></li>
</ul>
</div>
</div>
<div id="page">
<div class="post" id="content">
<h1 class="title"><?php echo $body_h1; ?></h1>
<p class="meta"></p>
<div class="entry">
<?php echo $body_entry; ?>
</div>
</div>
</div>
</div>
<div id="bgbottom" >
<div id="footer" >
<p>Copyright © 2010-2011.</p>
</div></div>

<div id="bglayout" ><div id="bgtop" ><div id="bgmenu" ><div class="left" ></div><div class="right" ></div></div></div></div>

</body>
</html>

Open in new window


page.php
<?php
$head_title = 'Browser title';
$head_keywords = 'php include template';
$head_description = 'example of a template based website';
$body_h1 = 'page1';
ob_start();
?><p>Here comes your normal content in html</p>
<p>And another line</p>
<?php
$body_entry = ob_get_clean();

include('template.tpl');
?>

Open in new window

0
 
LVL 16

Author Comment

by:SSupreme
ID: 36557455
I like it. What are page.php and template.php?
template.php should be used as it is;
page.php I can fill with whatever I like and create same pages with different content for other pages, like index.php?
Do I need to worry about template.tpl?
0
 
LVL 10

Expert Comment

by:acbxyz
ID: 36557477
page.php can be copied to as many pages as you need, including index.php. Those are called by clients.

template.php, or better call it template.inc.php, is not intend to be called by a client directly, but in this case it is would be no problem.

If naming it template.inc.php you can add the following lines to your .htaccess to deny access to any .inc.php files
<Files "*.inc.php">
    Order allow,deny
    Deny from all
</Files>

Open in new window

0
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 
LVL 16

Author Closing Comment

by:SSupreme
ID: 36557492
Obviously you answered the question.
But how page.php will call template.php, does it know that template.tpl is template.php?

Thank you very much indeed.
0
 
LVL 10

Expert Comment

by:acbxyz
ID: 36559573
Nope, that was a typo. The include command must have the exact filename of your template file.
If you call it template.tpl.php (as I do usually), you have to write include('template.tpl.php'); if you name it template.inc.php, it's include('template.inc.php'); and so on.
0
 
LVL 16

Author Comment

by:SSupreme
ID: 36563855
Thanks! I got it logically. I wanted to be sure.
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MySQL 6 46
PHP processing webform 25 44
Google Recaptcha 13 51
How do I init a PHP page jusing JQuery? 8 27
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question