• 0

How to add a PHP include tag on this site...


Question

I have a website with index.php (along with other pages) and an includes.php file. Can anyone help me figure out how I can add just the meta description and meta keywords tag in the includes file so I can add it on the individual pages how it's setup for the title tag. Any help would be great. Thanks:

includes.php :

<?

// ---- pageheader ----------------------------------------------------------------------------
function pageheader($title,$headbanner="body",$headerinsert="") {

  global $activetab;
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">          
<html>
<head>
<title><? echo "$title"; ?></title>
<link rel="stylesheet" type="text/css" href="/style.css">
<? echo "$headerinsert\n"; ?>

index.php

<?
require("global.php");

$activetab = 1;

pageheader("THIS IS THE LINE FOR THE TITLE TAG");
?>

//Body starts here:
         <div class="package">

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

In example.php you would include:

<?
$subtitle = "Custom Page Title";
$metadesc = "This is the desc for the page";
$metatags = "Keyword, Goes, Here";
include('header.php');
?>

In header.php you would include:

<title><? if (isset($subtitle)) { echo $subtitle; } ?></title>
<meta name="description" content="<? if (isset($metadesc)) { echo $metadesc; } ?>"> 
<meta name="keywords" content="<? if (isset($metatags)) { echo $metatags; } ?>"> 

BTW, when you post your code on a forum, you can use [ code][/ code] (sans the spaces) so it's in a pretty color coded syntax block :).

Link to comment
Share on other sites

  • 0

Hi Cupcakes,

Thanks for the quick response. Is there anyway I can integrate it within the current function "pageheader" without having to create a new header file? If not, how can I place the example/header you provided in my includes/index files. (Sorry, I'm still fairly new to php).

Link to comment
Share on other sites

  • 0

Just resolved this problem and wanted to post it in case if someone else is encountering a similar problem:

index.php file:

pageheader("Quality and Low Price Dedicated, VPS, and shared hosting for your business - LBI Hosting", "body",
 "<meta name=\"description\" content=\"Add text \"  />
<meta name=\"keywords\" content=\"Add text \"  />");
?>

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.