CodeCanyon

Dynamic metas

3384 posts
  • Australia
  • Bought between 100 and 499 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Interviewed on the Envato Notes blog
  • Microlancer Beta Tester
  • Sold between 1 000 and 5 000 dollars
Australia says

Is there a way ( not WP ) by the way, of generating dynamic metas?

I dont mean random, and essentially i am talking of description tag only.

I was gonna fire php include in the description tag , and wondered can we append an id / var to that include…sort of like a hashtag.

Then the include file would be a list we create prepended by id ..so as an example.

Page about.php loads and calls include/metas.php#about

Then in include file we somehow reference tht id ?

Any suggestions ?

624 posts
  • Exclusive Author
  • Sold between 100 and 1 000 dollars
  • Bought between 10 and 49 items
  • Has been a member for 0-1 years
  • Haiti
Crakken says
3384 posts
  • Australia
  • Bought between 100 and 499 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Interviewed on the Envato Notes blog
  • Microlancer Beta Tester
  • Sold between 1 000 and 5 000 dollars
Australia says

Try it first, then tell us what you get. These may be helpful:
http://voices.yahoo.com/use-php-generate-dynamic-meta-tags-634388.html?cat=35
http://stackoverflow.com/questions/10689600/generate-dynamic-meta-tags-based-on-url

Yer nah all of that I can inc canonical urls etc. Same for all other meta tags.

The issue I have is with Description Tag. I dont want to scrape page, for this particular exercise . I want to create my include file with like a ul li list ( obviously it wouldnt be that ) but a list so like:

#about = We are a great company based in Alaska
#contact = You can contact our offices anytime
#faq = frequently asked questions..

blah blah blah..

then in head of say about page: <?php include(’/includes/metas.php?about’); ?>

etc etc

Im not that savvy with php, but enough to get me by. Just wondered if a include ( i know by definition INCLUDES the content specified ) but could load particular DATA from a singular url

4 posts
  • Bought between 100 and 499 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 1 000 and 5 000 dollars
malky66 says

You could try this:

Create a file called metas.php and paste the following code:
<?php
if($page=='about'){$description='We are a great company based in Alaska';}
if($page=='contact'){$description='You can contact our offices anytime';}
if($page=='faq'){$description='frequently asked questions..';}
?>
etc..etc

Add the following to each page before you call the metas.php file and before the meta description tag

$page='contact'; on the contact page
$page='about'; on the about page..etc..etc
and call the <?php include(’/includes/metas.php’); ?> in the head of each page and use the meta description tag like this:
<meta name="description" content="<?php echo $description ?>" />

I havent tested it but it should work

Mal

3384 posts
  • Australia
  • Bought between 100 and 499 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Interviewed on the Envato Notes blog
  • Microlancer Beta Tester
  • Sold between 1 000 and 5 000 dollars
Australia says

Cheers yup thats exactly what we ave decided to do, great explanation. Thankyou…wheres the thanks button :)

624 posts
  • Exclusive Author
  • Sold between 100 and 1 000 dollars
  • Bought between 10 and 49 items
  • Has been a member for 0-1 years
  • Haiti
Crakken says
Oops, I already forgot about this thread, here is a another way (Haven’t tested): Create the file called metas.php and put in this snippet of code:
<?php
if ($_GET["page"] == "about") {
    $description = "We are a great company based in Alaska";
} elseif ($_GET["page"] == "contact") {
    $description = "You can contact our offices anytime";
} elseif ($_GET["page"] == "faq") {
    $description = "frequently asked questions..";
} else {
    $description = "Whatever else you want...";
}
?>
Then call the metas.php file on each page like that:
<?php include("/includes/metas.php?page=about"); ?> for the about description and do the same for the others.
Now on each page, just do:
<meta name="about" description="<?php echo $description; ?>" />
3384 posts
  • Australia
  • Bought between 100 and 499 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Interviewed on the Envato Notes blog
  • Microlancer Beta Tester
  • Sold between 1 000 and 5 000 dollars
Australia says

Thanks @cracken

Thats cool :) Appreciate your effort, thankyou very much. Have now completed it all, across entire site. Works a charm :)

Ste

624 posts
  • Exclusive Author
  • Sold between 100 and 1 000 dollars
  • Bought between 10 and 49 items
  • Has been a member for 0-1 years
  • Haiti
Crakken says

Thanks @cracken

Thats cool :) Appreciate your effort, thankyou very much. Have now completed it all, across entire site. Works a charm :)

Ste

No problem. It’s “Crakken” by the way ;)

3384 posts
  • Australia
  • Bought between 100 and 499 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Interviewed on the Envato Notes blog
  • Microlancer Beta Tester
  • Sold between 1 000 and 5 000 dollars
Australia says

Lol sorry, worked thru the night.

Always reminds me an old joke , Phil McCrakken …best not expand on that

624 posts
  • Exclusive Author
  • Sold between 100 and 1 000 dollars
  • Bought between 10 and 49 items
  • Has been a member for 0-1 years
  • Haiti
Crakken says

Lol sorry, worked thru the night. Always reminds me an old joke , Phil McCrakken …best not expand on that

Lol, actually it’s Phil “McCracken” but it’s okay :P

by
by
by
by
by