Page 1 of 1

Re: PHP and Meta Data

Posted: Mon Aug 17, 2009 1:59 pm
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?

Re: PHP and Meta Data

Posted: Mon Aug 17, 2009 6:13 pm
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.

Re: PHP and Meta Data

Posted: Mon Aug 17, 2009 6:37 pm
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.

Re: PHP and Meta Data

Posted: Mon Aug 17, 2009 7:02 pm
by jackpf
Good point.

Re: PHP and Meta Data

Posted: Tue Aug 18, 2009 5:58 am
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.

Re: PHP and Meta Data

Posted: Tue Aug 18, 2009 9:32 am
by jackpf

Code: Select all

$page = 'index';
generate_meta($page);

Re: PHP and Meta Data

Posted: Wed Aug 19, 2009 12:18 pm
by jackpf
You could do this:

Code: Select all

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