473,385 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How do I dynamically set the meta tags in an included header from each html page?

I have a header.php file containing the following code...

Expand|Select|Wrap|Line Numbers
  1. ...
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title><?php echo $tpTitle ?></title>
  6. <meta name="description" content="<?php echo $pgDesc ?>"></meta>
  7. <meta name="keywords" content="<?php echo $pgKeywords ?>"></meta>
  8. ...
  9.  
In my other .php pages I want to be able to set the variables in the included header file.

I have:
Expand|Select|Wrap|Line Numbers
  1. <?php include("../incl/header.php"); ?>
  2. <?php
  3. $tpTitle="Page title";
  4. $pgHeading="";
  5. $pgDesc="page description";
  6. $pgKeywords="page keywords";
  7. ?>
  8.  
  9. <body id="courses">
  10. <?php include("../incl/nav.php"); ?>
  11. ...
  12.  
I know this doesn't set the variables in the required page. Can someone let me know what the format for doing so is?
Oct 6 '10 #1
1 2416
Markus
6,050 Expert 4TB
It doesn't work like that. You'll have to define the variables before the include.
Oct 6 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

24
by: Day Bird Loft | last post by:
Web Authoring | Meta-Tags The first thing to understand in regard to Meta Tags is the three most important tags placed in the head of your html documents. They are the title, description, and...
4
by: clintonG | last post by:
Anybody know how to dynamically write the meta tags using code so they are formatted on a separate line in the HTML source? Preferred or optimal framework classes that may be used in this regard? ...
3
by: rahman | last post by:
I have few hundred HTML pages. I need to extract portion of each HTML page into a text/database/HTML files format. You can imagine it is very tedious to do one by one. Is there any automatic...
0
by: Mike Collins | last post by:
I am trying to render an HTML page into MS Word. The document is dynamically built based on what is stored in our database. I've done this in classic ASP with just an Html meta tag, if I remember...
2
by: Dariusz Tomon | last post by:
Hello How can I build meta tags dynamically? Please provide an example. Thank you Dariusz Tomon
4
by: bashetty | last post by:
Well its a strange problem i have, some of you might already faced it and have a solution. I have to maintain a set of unique "search key words" in meta tags for each content page in my site. With...
2
by: thetechturf.com | last post by:
I have some simple dynamic content pages (included below). I need to know how to add specific meta tags (ie. description, keywords, ect.), as well as extra specific header coding to a page. I would...
21
by: karen987 | last post by:
I have a news website, with asp pages. It has publishing software which allows you to add articles in a database, and then calls them up from links etc. I have added dynamic meta tags in 2 parts. The...
9
by: Chuck [Sbc\) | last post by:
I am new to html programming. I have created a web with 17 different pages. On each page is a button menu which allow the user to switch to another page without returning to the home page . The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.