Jump to content
Larry Ullman's Book Forums

Recommended Posts

I notice in your code that when using a template format you have the header and footer code and You include the title with a variable. Is there a way to do that with the meta tags as well. Thanks

Share this post


Link to post
Share on other sites

Define the meta tags information in a variable? Depending on the meta tag and the page it's going on you will probably need some way calling the correct meta information. I store mine in a table using a series of Primary and foreign keys to retrieve them.

  • Upvote 1

Share this post


Link to post
Share on other sites

well in most of the examples in the book. for the $page_title var it will be like $page_title = "About Us" or something of that nature. I was just curious is there was a similar way to do meta info

 

becasue I wast planning on doing something like the following

 

<?php

//can something like this be done

$meta_info ="Something Something";

$page_title = 'PDFS';

include('./includes/header.html');

 

some info

 

include('./includes/header.html');

 

?>

Share this post


Link to post
Share on other sites

Sure, you can do that. You'll just need to have some PHP in your header.html that echoes that if it exists:

<html>

<head>
<title><?php if (isset ($page_title) { echo $page_title; } ?></title>
<?php if (isset ($meta_info) { echo $meta_info; } ?>
</head>

  • Upvote 1

Share this post


Link to post
Share on other sites

You can also use DHTML to add meta tags on the fly.

 

In other words, you can use JavaScript to dynamically add meta tags to the page. That, however, is a client-side solution, and is removed from PHP. The choice is yours.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...