..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: PHP and Meta Data

Post by jackpf »

Have a function in meta.php which generates the meta data, and pass it an argument of the page you want the data for maybe?
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: PHP and Meta Data

Post by jackpf »

Code: Select all

function generate_meta($page)
{
switch($page)
{
case 'index':
return 'meta ddata for the index page';
break;
case 'another page':
return 'meta data for another page';
break;
}
}
Like that.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: PHP and Meta Data

Post by John Cartwright »

Sounds like your meta data belongs in the database, which can easily be queried for. Loading a potentially large file of meta data when we will only be using specific elements seems like a waste of cycles.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: PHP and Meta Data

Post by jackpf »

Good point.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: PHP and Meta Data

Post by jackpf »

You'd pass it as an argument to the function.

But the same concept can apply to the database. Have a column called `Page` or something, and select the details for whatever page you're on.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: PHP and Meta Data

Post by jackpf »

Code: Select all

$page = 'index';
generate_meta($page);
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: PHP and Meta Data

Post by jackpf »

You could do this:

Code: Select all

$page = reset(explode('.', basename(__FILE__)));
Post Reply