referencing filename code almost there cant find bug

Hi I have a page address called www.sitename.com/content/aboutme.php

Current code on main page calling content named aboutme_content.php

aboutme_content.php references text to include using

<?php echo $aboutmesubtitle1content ?>

Im trying to get pull the mainpage filename only so “aboutme” and use it as a prefix in the echo line changing

<?php echo $aboutmesubtitle1content ?> <?php echo $subtitle1content ?>

I have tried adapting this code but cant get it to work. Can you spot why this isn’t working. I have thought it may be that I am not referencing the parent page filename perhaps but cant think of how to prove it, or that I have placed echo in the wrong place or possibly another error.

<?php
    // Get the current page filename
    $include_file = __FILE__;

    // Remove the file extension .php (or any other file extension)
    function remove_extension($filename) {
      $ext = pathinfo($filename, PATHINFO_EXTENSION);
      return preg_replace('/\.' . preg_quote($ext, '/') . '$/', '', $filename);
    }
    $include_file =  echo remove_extension($include_file);

    // Add "_content.php"
    $include_file .= 'subtitle2content ';
    ?>

Any help much appreciated.

Thanks Rob

I have a question, why are you changing the variable name? (is it required to be explicitly changed elsewhere in the script?)

It don’t/shouldn’t matter what the variable name is, as it is the value of that variable you want to change, not the name.
Example:
[php]
$a = ‘this is some data’;
echo $a; // output: this is some data

$a = ‘this data has now changed’;
echo $a; // output: this data has now changed

$a = ‘even though the variable remains the same’;
echo $a; // output: even though the variable remains the same[/php]

So, for what you wish to do you should change the value of subtitle1content at run time.
For example:

select subtitle from database where content = pagename

Make sense?

If you start changing variable names on the fly, your code will very soon become unmaintainable as variables will be created/dropped all over the place.

Hope that helps, if you wish me to help you out, either post up some more info or contact me via the link in my footer.

Cheers,
Red. :wink:

Hi
Thanks for your reply,

The reason for wanting to do this is to set a naming convention for my pages so for example

tree.php has meta and title and sub content that I want to pull text from my variables file so I can simply copy the page files and rename them and their variables will not need editing inside so instead of referencing the title lets say as

<?php echo $treespagetitle;?>

the trees part will come from the filename so I dont have to enter the page and alter trees to plants or gardens etc

Hope this makes sense and i think this code is almost correct?

<?php
// Get the current page filename
$include_file = __FILE__;

// Remove the file extension .php (or any other file extension)
function remove_extension($filename) {
  $ext = pathinfo($filename, PATHINFO_EXTENSION);
  return preg_replace('/\.' . preg_quote($ext, '/') . '$/', '', $filename);
}
$include_file = remove_extension($include_file);

// Add "pagetitle"
$include_file .= 'pagetitle';

// Include the file if it exists
if(file_exists($include_file)) {
  include($include_file);
}
?>

Concatenating filename with no file extension + variable end reference

Thanks Rob

Sorry to repeat myself but a better example and explanation is that I have a model for the site where I call all the pages by a name lets call it example

example.php and all example.php content is referenced from variables.php so the title, meta, headings, text content everything text comes from the variables file. This is good for editing quickly.

here are a few examples of where im using the references

<meta name="description" content="<?php echo $examplemetadescription;?>" />
<meta name="keywords" content="<?php echo $examplekeywords;?>" />
<meta name="author" content="<?php echo $exampleauthor;?>" />
<meta name="robots" content="<?php echo $examplerobots;?>" />

<link rel="stylesheet" type="text/css" href="genericpagestyle.css" media="screen" />

<title>website-name.com | <?php echo $examplepagetitle;?></title> 

variables.php has a list of the text and adds it when the page is loaded in the browser so the file for the above looks like

$examplepagetitle="Page Title";
$examplemetadescription="The Page Description for meta"

etc etc

I know this is a standard model so what I want to do is go one step further and save time having to edit all the explicit examples when creating new pages. Some code i found to start this is

    <?php
    // Get the current page filename
    $include_file = __FILE__;

    // Remove the file extension .php (or any other file extension)
    function remove_extension($filename) {
      $ext = pathinfo($filename, PATHINFO_EXTENSION);
      return preg_replace('/\.' . preg_quote($ext, '/') . '$/', '', $filename);
    }
    $include_file = remove_extension($include_file);
    ?>

Can you help me finish it off so i can add to each of the references to concatenate filename with variable end reference.

Thanks Rob

does this mean you are going to have a separate file for each page with named variables as place holders for every meta/title/content?

When I build a site, the index page is nothing more than a set of instructions that figures out which page the user is requesting, fetches all relevant data (meta tags, title, content, footer etc.) and displays the content using a template page. (or an alternate template if I need to drastically change the layout for a particular page.)
All logic/html are kept separated as much as possible. (MVC)

The point I’m getting at is, unless I’ve misunderstood, you’re creating a whole lot of unnecessary work for yourself and probably a load of unnecessary problems to go with it!

As opposed to:
tree.php
flower.php
forest.php
woods.php

You only need:
index.php // this file will figure out what data is required and fetch it from the database.
template.php // this file will display the data.

index.php:
[php]<?php
$page = $_GET[‘page’];
$query = “SELECT meta, title, content FROM database WHERE page=’” . $page . “’”;
include_once ‘/templates/template.php’;[/php]

template.php:
[php]

<?php echo $title; ?> <?php echo content; ?> [/php]

This is a very rough draft and more code is required to make it work but I hope it gives you the general idea of the point I’m trying to make.

If, like I said in the beginning I have completely missed the point then please say so and we’ll get to the bottom of it, otherwise maybe you should rethink what you’re trying to achieve (and why?) and then figure out the best way to do it.

Feel free to give me a shout, I’ll be glad to help either way.
Red :wink:

EDIT
I have just noticed your new post after I submitted this one, give me a few mins to read through your new post and I’ll edit this to show any new answers.

Ok, I read your new post,
Are you going to change the variable names in variable.php and write a new file? (with the new names)

Hi thanks yes variables would have the standard content added in a list for each new page allowing one file variables.php to be the reference point for all text on every page to come in from

Ok, I understand what you’re doing, just don’t understand why?

This should do what you require:
[php]function return_partfilename($url) {
$arr = explode(’/’, $url);
return substr($arr[sizeof($arr)-1], 0, strpos($arr[sizeof($arr)-1], ‘_’));
}

// url to strip…
$url = ‘abc/def/aboutme_content.php’;

// show unaltered var…
$include_file = ‘subtitle2content’;
echo $include_file;
//output: subtitle2content

// show altered var using function…
$include_file = return_partfilename($url) . ‘subtitle2content’;
echo $include_file;
//output: aboutmesubtitle2content[/php]

If there will always be an underscore in the include filepath then you don’t need to specifically chop off the extension. Using substr i chop it at the underscore, much easier…

Hope that helps,
Red :wink:

Hi Red

This is starting to work, after a lot of testing it I have the code adapted the code but its still not quite there…

The original looked like this -

<?php echo $aboutmetitlecontent ?>

replaced with modified suggestion -

	<?php 
	function return_partfilename($url) {
	$arr = explode('/', $url);
	return substr($arr[sizeof($arr)-1], 0, strpos($arr[sizeof($arr)-1], '_'));
	}

	// url to strip..
	$url =  __FILE__;

	// show unaltered var..
	$include_file = '$';
	echo $include_file;
	//output: subtitle2content

	// show altered var using function..
	$include_file = return_partfilename($url) . 'titlecontent';
	echo $include_file;
	//output: aboutmesubtitle2content
	?>

The FILE addition uses the actual url which is what I wanted so that adaptation has worked

The problem is it prints the output on the page as text like

$aboutmetitlecontent

rather than using it and pulling the line

$aboutmetitlecontent='This is the section about me';

from the variables.php file

Hopefully you will see what im doing now

Regards
[/code]

I still can’t get my head around why you would want to change variable names on the fly, I’ve been coding PHP since the 90’s and I don’t recall ever having to do what you’re trying to do, it’s just not necessary :o

Can you post the full variables.php file and any one of the pages that use variables.php
I need to see the actual code before I offer any more solutions as I suspect I may be able to simplify your code for you.

Red :wink:

Thanks this is the variables file im using it as a database to pull text into all the pages making it one easy point to adjust all text on all pages from titles, sidebar, content - everything


<?php
 
$heading='robert-hargreaves.com';
$footer='&#169; 2013 robert-hargreaves.com';

$aboutmepagetitle="About me";
$aboutmemetadescription="Energy Efficiency, BioEnergy, Innovation, Logistics, Self Sufficiency, Water Footprint, Environmental Sustainability";
$aboutmekeywords="meta description,google meta description,meta name description, Anaerobic Digestion, CHP, Export Management, Demand Reduction, Efficiency, Tariff Management, Environmental Permitting, Control & Automation, Remote & Self Optimising Systems Development, Anaerobic Digestion, CHP, National Grid Export, Energy Contract Management, Energy Consumption Analysis, Demand Reduction Management, Efficiency Engineering, Tariff Management, Systems Development, Environmental Permitting, Control, Automation, Upgrading Systems to, Remote, Self Optimising Logistics, Innovation, Change Management, Operations Science IT – Telemetry and Systems, Waste Management Reduction, Food Miles, Water Footprint, Environmental, Sustainability Self Sufficiency";
$aboutmeauthor="Robert Hargreaves, UK";
$aboutmerobots="index,follow";

$aboutmetitle='About me';
$aboutmetitlecontent='This is the section about me';
$aboutmesubtitle1='Interests';
$aboutmesubtitle1content='Energy, etc, etc...';
$aboutmesubtitle2='More on me';
$aboutmesubtitle2content='This is an optional section and this is example text';

$anaerobicdigestionpagetitle="About me";
$anaerobicdigestionmetadescription="Energy Efficiency, BioEnergy, Innovation, Logistics, Self Sufficiency, Water Footprint, Environmental Sustainability";
$anaerobicdigestionkeywords="meta description,google meta description,meta name description, Anaerobic Digestion, CHP, Export Management, Demand Reduction, Efficiency, Tariff Management, Environmental Permitting, Control & Automation, Remote & Self Optimising Systems Development, Anaerobic Digestion, CHP, National Grid Export, Energy Contract Management, Energy Consumption Analysis, Demand Reduction Management, Efficiency Engineering, Tariff Management, Systems Development, Environmental Permitting, Control, Automation, Upgrading Systems to, Remote, Self Optimising Logistics, Innovation, Change Management, Operations Science IT – Telemetry and Systems, Waste Management Reduction, Food Miles, Water Footprint, Environmental, Sustainability Self Sufficiency";
$anaerobicdigestionauthor="Robert Hargreaves, UK";
$anaerobicdigestionrobots="index,follow";

$anaerobicdigestiontitle='Experience';
$anaerobicdigestiontitlecontent='Digestion is natures way of breaking down organic waste, naturally it occurs when a product is left open to air.  Whatever happens it will decompose, from the moment its taken from source unless it is preserved.';
$anaerobicdigestionsubtitle1='Experience';
$anaerobicdigestionsubtitle1content='10 Years Experience in the design, specification, standards, projects, upgrade, consolidation, decomissioning, operation, feedstock optimisation and technical management';
$anaerobicdigestionsubtitle2='Further Reading';
$anaerobicdigestionsubtitle2content='This is the detail of the third section';

?>

This is the page code for - “aboutme.php” the one viewed on the internet

<?php include('./variables/variables.php'); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8" />


<meta name="description" content="<?php echo $aboutmemetadescription;?>" />
<meta name="keywords" content="<?php echo $aboutmekeywords;?>" />
<meta name="author" content="<?php echo $aboutmeauthor;?>" />
<meta name="robots" content="<?php echo $aboutmerobots;?>" />


<link rel="stylesheet" type="text/css" href="genericpagestyle.css" media="screen" />

<title>robert-hargreaves.com | <?php echo $aboutmepagetitle;?></title> 

<link href='http://fonts.googleapis.com/css?family=Archivo+Black' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Archivo+Narrow:700' rel='stylesheet' type='text/css'>
	 
<!DOCTYPE HTML>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="animatedcollapse.js"></script>

<script type="text/javascript">

animatedcollapse.addDiv('titlecontent', 'fade=0,height=100%')
animatedcollapse.addDiv('subtitle1content', 'fade=0,height=100%')
animatedcollapse.addDiv('subtitle2content', 'fade=0,height=100%')

animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted
	//$: Access to jQuery
	//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID
	//state: "block" or "none", depending on state
}

animatedcollapse.init()
</script>	 

<script type="text/javascript">
animatedcollapse.addDiv('jason', 'optional_attribute_string')
//additional addDiv() call...
//additional addDiv() call...
animatedcollapse.init()
</script>
	 
</head>
 
<body>

 <p>
	<?php include('includes/header.php'); ?> 
 </p>

 <div id="wrapper">
 	<div id="innerwrapper">
	
    <?php
    // Get the current page filename
    $include_file = __FILE__;

    // Remove the file extension .php (or any other file extension)
    function remove_extension($filename) {
      $ext = pathinfo($filename, PATHINFO_EXTENSION);
      return preg_replace('/\.' . preg_quote($ext, '/') . '$/', '', $filename);
    }
    $include_file = remove_extension($include_file);

    // Add "_content.php"
    $include_file .= '_content.php';

    // Include the file if it exists
    if(file_exists($include_file)) {
      include($include_file);
    }
    ?>
		<?php include('includes/sidebar.php'); ?>
	</div>
 </div> <!-- End #wrapper -->

 <p>
	<?php include('includes/footer.php'); ?>
 </p>
 
</body>
</html>

There is a file named - aboutme_content.php that is referenced above using some code that I am tryign to adapt. this is the code for that…

<?php include('./variables/variables.php'); ?>

<div id="content">
<div id="contentwrapper">
<p id="title"align="left"><b><?php echo $aboutmetitle ?></b>
	<a href="javascript:animatedcollapse.toggle('titlecontent');javascript:animatedcollapse.hide(['subtitle1content', 'subtitle2content'])"><img src="./img/down.jpg" height="7" width="12" border="0" /></a>
</p>

<div id="titlecontent" style="width:100%;>
	<p align="left">
	<?php 
	function return_partfilename($url) {
	$arr = explode('/', $url);
	return substr($arr[sizeof($arr)-1], 0, strpos($arr[sizeof($arr)-1], '_'));
	}

	// url to strip..
	$url =  __FILE__;

	// show unaltered var..
	$include_file = '$';
	echo $include_file;
	//output: subtitle2content

	// show altered var using function..
	$include_file = return_partfilename($url) . 'titlecontent';
	echo $include_file;
	//output: aboutmesubtitle2content
	?>
</p>
</div>

<p id="subtitle1"align="left"><b><?php echo $aboutmesubtitle1 ?></b>
	<a href="javascript:animatedcollapse.toggle('subtitle1content');javascript:animatedcollapse.hide(['titlecontent', 'subtitle2content'])"><img src="./img/down.jpg" height="7" width="12" border="0" /></a> 
</p>

<div id="subtitle1content" style="width:100%; display:none">
	<p align="left"><?php echo $aboutmesubtitle1content ?></p>
</div>

<p id="subtitle2"align="left"><b><?php echo $aboutmesubtitle2 ?></b>
	<a href="javascript:animatedcollapse.toggle('subtitle2content');javascript:animatedcollapse.hide(['titlecontent', 'subtitle1content'])"><img src="./img/down.jpg" height="7" width="12" border="0" /></a> 
</p>

<div id="subtitle2content" style="width:100%; display:none">
	<p align="left"><?php echo $aboutmesubtitle2content ?></p>
</div>
</div>
</div> 

Its all working well but when I use your advice in the last part (see last code window) this is where I am getting it just printing out instead of referencing the variables.php file

Hope this all makes sense
[/code]

The main reason im doing this is to be able to have a site I can replicate in about 20 minutes

I have a batch file that replicates the template and creates file names based on the contents of a text file because all the pages are driven to their filename for all link addresses it means no page editing is needed

I will only have to alter one text file once its set up

the variables.php page you have posted below,

about me & anaeraobic digestion variables,

am I correct in assuming this is data for two different pages?

Hi Red

All the pages work together, the aboutme.php is the main page, aboutme_content.php is a part of aboutme.php and variables.php holds the text for the pages.

you can visit the page at
http://www.robert-hargreaves.com/content/aboutme.php

Rob

Sorry and the aboutme and anaerobicdigestion variables are for two different pages one of them is called aboutme.php and the other is called anaerobicdigestion.php

Hopefully that makes sense

ok, I have put together a working solution for you, not exactly how i’d do it myself but i didn’t want to change your structure too much, try this and let me know how you get on:

variables.php
[php]<?php
/**

/**

  • Meta data.
    **/
    $pagetitle=“About me”;
    $metadescription=“Energy Efficiency, BioEnergy, Innovation, Logistics, Self Sufficiency, Water Footprint, Environmental Sustainability”;
    $keywords=“meta description,google meta description,meta name description, Anaerobic Digestion, CHP, Export Management, Demand Reduction, Efficiency, Tariff Management, Environmental Permitting, Control & Automation, Remote & Self Optimising Systems Development, Anaerobic Digestion, CHP, National Grid Export, Energy Contract Management, Energy Consumption Analysis, Demand Reduction Management, Efficiency Engineering, Tariff Management, Systems Development, Environmental Permitting, Control, Automation, Upgrading Systems to, Remote, Self Optimising Logistics, Innovation, Change Management, Operations Science IT Telemetry and Systems, Waste Management Reduction, Food Miles, Water Footprint, Environmental, Sustainability Self Sufficiency”;
    $author=“Robert Hargreaves, UK”;
    $robots=“index,follow”;

/**

  • Fetch the correct data for the page called.
    /
    switch($getpage) {
    case ‘aboutme’ :
    /

    * About Me.
    **/
    $pagetitle=‘About me’;
    $pagetitlecontent=‘This is the section about me’;
    $pagesubtitle1=‘Interests’;
    $pagesubtitle1content=‘Energy, etc, etc…’;
    $pagesubtitle2=‘More on me’;
    $pagesubtitle2content=‘This is an optional section and this is example text’;
    break;

    case ‘anaerobicdigestion’ :
    /**
    * Anaerobic Digestion.
    **/
    $pagetitle=‘Experience’;
    $pagetitlecontent=‘Digestion is natures way of breaking down organic waste, naturally it occurs when a product is left open to air. Whatever happens it will decompose, from the moment its taken from source unless it is preserved.’;
    $pagesubtitle1=‘Experience’;
    $pagesubtitle1content=‘10 Years Experience in the design, specification, standards, projects, upgrade, consolidation, decomissioning, operation, feedstock optimisation and technical management’;
    $pagesubtitle2=‘Further Reading’;
    $pagesubtitle2content=‘This is the detail of the third section’;
    break;

    default :
    /**
    * Homepage
    **/
    $pagetitle=‘Home’;
    $pagetitlecontent=‘Welcome to our website.’;
    $pagesubtitle1=‘Home’;
    $pagesubtitle1content=‘Thank you for stopping by.’;
    $pagesubtitle2=‘Further Reading’;
    $pagesubtitle2content=‘This is the detail of the third section’;
    break;
    }
    ?>[/php]

This next page should be saved as whatever you want the link to be, IE: index.php, aboutme.php etc.
[php]<?php
$getpage = substr(substr($_SERVER[‘SCRIPT_NAME’], 0, strrpos($_SERVER[‘SCRIPT_NAME’], ‘.’, -1)), strrpos($_SERVER[‘SCRIPT_NAME’], ‘/’, -1)+1);
include(‘variables.php’);
?>

robert-hargreaves.com | <?php echo $pagetitle;?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="animatedcollapse.js"></script>
<script type="text/javascript">
	animatedcollapse.addDiv('titlecontent', 'fade=0,height=100%')
	animatedcollapse.addDiv('subtitle1content', 'fade=0,height=100%')
	animatedcollapse.addDiv('subtitle2content', 'fade=0,height=100%')
	animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted
		//$: Access to jQuery
		//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID
		//state: "block" or "none", depending on state
	}
	
	animatedcollapse.init()
</script>	 
<script type="text/javascript">
	animatedcollapse.addDiv('jason', 'optional_attribute_string')
	//additional addDiv() call...
	//additional addDiv() call...
	animatedcollapse.init()
</script>

<?php include('includes/header.php'); ?>

<?php echo $pagetitle ?>

			<div id="titlecontent">
				<p align="left"><?php echo $pagetitlecontent; ?></p>
			</div>
			
			<p id="subtitle1" ><b><?php echo $pagesubtitle1 ?></b>
				<a href="javascript:animatedcollapse.toggle('subtitle1content');javascript:animatedcollapse.hide(['titlecontent', 'subtitle2content'])"><img src="./img/down.jpg" height="7" width="12" border="0" /></a> 
			</p>
			
			<div id="subtitle1content">
				<p align="left"><?php echo $pagesubtitle1content ?></p>
			</div>
			
			<p id="subtitle2"><b><?php echo $pagesubtitle2 ?></b>
				<a href="javascript:animatedcollapse.toggle('subtitle2content');javascript:animatedcollapse.hide(['titlecontent', 'subtitle1content'])"><img src="./img/down.jpg" height="7" width="12" border="0" /></a> 
			</p>
			
			<div id="subtitle2content">
				<p align="left"><?php echo $pagesubtitle2content ?></p>
			</div>
		</div>
	</div> 
<?php
include('includes/sidebar.php'); 
?>
</div>

<?php include('includes/footer.php'); ?>

[/php]

It means your going to have a load of files, with the same code written, just a different name.
Not the best way, but it works.
If it was me, I’d come up with a solution that would allow me to have the last file written just once.

Red :wink:

Hi red,

This is absolutely brilliant, thanks for your help.

The build is complete now just for the content.

One last question though is how to bring the meta into page specific so the variables file looks like this

i have noticed that the ’ and " are used but guess this is fine as the meta will have to be displayed in so I have tried variances such as

$metapagetitle='"About me"';

but it doesnt work

<?php
/**
* Header & Footer.
**/
$heading='robert-hargreaves.com';
$footer='&#38;#38;#169; 2013 robert-hargreaves.com';

switch($getpage) {

case 'aboutme' :

$metapagetitle="About me";
$metadescription="Energy Efficiency, BioEnergy, Innovation, Logistics, Self Sufficiency, Water Footprint, Environmental Sustainability";
$metakeywords="meta description,google meta description,meta name description, Anaerobic Digestion, CHP, Export Management, Demand Reduction, Efficiency, Tariff Management, Environmental Permitting, Control & Automation, Remote & Self Optimising Systems Development, Anaerobic Digestion, CHP, National Grid Export, Energy Contract Management, Energy Consumption Analysis, Demand Reduction Management, Efficiency Engineering, Tariff Management, Systems Development, Environmental Permitting, Control, Automation, Upgrading Systems to, Remote, Self Optimising Logistics, Innovation, Change Management, Operations Science IT Telemetry and Systems, Waste Management Reduction, Food Miles, Water Footprint, Environmental, Sustainability Self Sufficiency";
$metaauthor="Robert Hargreaves, UK";
$metarobots="index,follow";

$pagetitle='About me';
$pagetitlecontent='This is the section about me';
$pagesubtitle1='Interests';
$pagesubtitle1content='Energy, etc, etc...';
$pagesubtitle2='More on me';
$pagesubtitle2content='This is an optional section and this is example text';
break;

case 'anaerobicdigestion' :

$metapagetitle="About me";
$metadescription="Energy Efficiency, BioEnergy, Innovation, Logistics, Self Sufficiency, Water Footprint, Environmental Sustainability";
$metakeywords="meta description,google meta description,meta name description, Anaerobic Digestion, CHP, Export Management, Demand Reduction, Efficiency, Tariff Management, Environmental Permitting, Control & Automation, Remote & Self Optimising Systems Development, Anaerobic Digestion, CHP, National Grid Export, Energy Contract Management, Energy Consumption Analysis, Demand Reduction Management, Efficiency Engineering, Tariff Management, Systems Development, Environmental Permitting, Control, Automation, Upgrading Systems to, Remote, Self Optimising Logistics, Innovation, Change Management, Operations Science IT Telemetry and Systems, Waste Management Reduction, Food Miles, Water Footprint, Environmental, Sustainability Self Sufficiency";
$metaauthor="Robert Hargreaves, UK";
$metarobots="index,follow";

$pagetitle='Experience';
$pagetitlecontent='Digestion is natures way of breaking down organic waste, naturally it occurs when a product is left open to air.  Whatever happens it will decompose, from the moment its taken from source unless it is preserved.';
$pagesubtitle1='Experience';
$pagesubtitle1content='10 Years Experience in the design, specification, standards, projects, upgrade, consolidation, decomissioning, operation, feedstock optimisation and technical management';
$pagesubtitle2='Further Reading';
$pagesubtitle2content='This is the detail of the third section';
break;

default :
$metapagetitle="About me";
$metadescription="Energy Efficiency, BioEnergy, Innovation, Logistics, Self Sufficiency, Water Footprint, Environmental Sustainability";
$metakeywords="meta description,google meta description,meta name description, Anaerobic Digestion, CHP, Export Management, Demand Reduction, Efficiency, Tariff Management, Environmental Permitting, Control & Automation, Remote & Self Optimising Systems Development, Anaerobic Digestion, CHP, National Grid Export, Energy Contract Management, Energy Consumption Analysis, Demand Reduction Management, Efficiency Engineering, Tariff Management, Systems Development, Environmental Permitting, Control, Automation, Upgrading Systems to, Remote, Self Optimising Logistics, Innovation, Change Management, Operations Science IT Telemetry and Systems, Waste Management Reduction, Food Miles, Water Footprint, Environmental, Sustainability Self Sufficiency";
$metaauthor="Robert Hargreaves, UK";
$metarobots="index,follow";

$pagetitle='Home';
$pagetitlecontent='Welcome to our website.';
$pagesubtitle1='Home';
$pagesubtitle1content='Thank you for stopping by.';
$pagesubtitle2='Further Reading';
$pagesubtitle2content='This is the detail of the third section';
break;
}
?>

As it is now when I do this the meta doesn’t work in the page.

Thanks Rob

in the scripts i wrote, $metapagetitle becomes simply $pagetitle (checkout the second script)
If you want to edit them for each page, just copy them into the switch statement then you can have different meta tags for each page. The reason I had them separate was in your files, they were all the same, thus lots of code repeated. (a habit you should not fall into)

Glad you got it working, if you need me again, you can find me here or the link in my footer.
Red :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service