Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 15th, 2004, 01:04 PM
Authorized User
 
Join Date: Nov 2003
Location: Butler, PA, USA.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to jefferis Send a message via AIM to jefferis Send a message via MSN to jefferis
Default Get meta tag from current page? PHP 4.x

I'm trying to update a client's static pages which have item descriptions in the 'description' meta tag content. I want to print the descriptions under the image on the existing page, which I am converting to php.

 I've checked out some of the get_meta_tag functions but am finding that they seem to require searching another page via a path. I'm trying to get the data on this current page. I'm wondering if the command structure will allow this and if there is an example that someone could point me to. It seems that since the info is given by the server as the page is created, any php function would kick in too late to display?

~~~~~~~~~~~~~
 http://www.petersonsales.net
__________________
~~~~~~~~~~~~~
 http://www.petersonsales.net
Reply With Quote
  #2 (permalink)  
Old September 15th, 2004, 05:04 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Without extracting the meta data and putting it in a database and then dynamically including it where ever you want, one possible hack is to access the DOM at the server level. PHP provides an extension for doing this, http://www.php.net/dom.

In order to use this extension on the current page as opposed to opening and accessing another separate page, the only way that I can think to do it is to use output control functions, or ensure that nothing is output and the whole page ends up stored in the same variable. The latter would be more efficient, I think, from a resource usage point of view. With the former you allow the page to be written to the output buffer, then capture the page using output control functions, modify what you need to and then output it. http://www.php.net/outcontrol.

Using this method you could, theoretically at least, access and modify the document similar to JavaScript on the client-side.

HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail
Reply With Quote
  #3 (permalink)  
Old September 15th, 2004, 08:06 PM
Authorized User
 
Join Date: Nov 2003
Location: Butler, PA, USA.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to jefferis Send a message via AIM to jefferis Send a message via MSN to jefferis
Default

Thanks. I guess I found it easier to do in javascript which will require less modification and programming to modify the few pages I need to.
Jeff

 function seeAll()
 {
 var metaContent = "";
 var allMetas = document.getElementsByTagName("meta");

 for(var i = 0; i < allMetas.length; i++)
 {
 if(allMetas[i].name == "description")
 {
 metaContent = allMetas[i].content;
 break;
 }
 }
 return metaContent;
 }



function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
 document.write(seeAll());

~~~~~~~~~~~~~
 http://www.petersonsales.net
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
<meta> tag is appearing in xml file saurabh_inblore XSLT 2 April 24th, 2006 11:56 PM
meta tag rajuru Beginning PHP 1 January 30th, 2005 09:27 AM
The "Meta Refresh Tag" method nancy HTML Code Clinic 5 October 28th, 2004 04:43 PM
Need meta tag help, please larry HTML Code Clinic 1 January 6th, 2004 07:45 AM
Meta tag problem? KHarrington HTML Code Clinic 4 November 5th, 2003 11:27 AM



All times are GMT -4. The time now is 04:45 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.