Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 02-24-2009, 09:30 PM Dynamic Meta Tag
stevej's Avatar
Professional Multitasker

Posts: 996
Location: Not positive
Trades: 0
So anyway, here is the deal. At the top of each page, there is a little meta tag, holding the page's 'title'. It looks similar to this:
HTML Code:
<META NAME="title" CONTENT="Test Page 1" />
I have a few pages like this. Now, I have a bit of code in my sidebar that looks like this:
PHP Code:
<?php
$path 
".";
$dir_handle = @opendir($path) or die("");
while (
$file readdir($dir_handle)) {
    
$tags = @get_meta_tags($file);
    if(
preg_match("/.php.bak/"$file)) {
        echo 
"";
    } else {
        if(
preg_match("/.php/"$file)) {
            echo 
"<a href='$file'>".$tags['title']."</a><br />";
        } else { 
            echo 
""
        }
    }    
}
closedir($dir_handle);
?>
The code takes all the content of the current directory, separates what is a good file and what is not, and then echos the meta content of the selected file out. Relatively simple. And so far, it works. But, if I add a PHP variable with the same content and use it for the meta instead of the static html content, like this:
PHP Code:
<?php $pagetitle "Test Page 1"?>
<META NAME="title" CONTENT="<?php echo $pagetitle?>" />
The title of the page itself won't show up inside the sidebar, along with all the pages that do. I suspect it has something to do with the loop, but I have no idea how to fix it. Any suggestions?

- Steve
__________________
if($stevej == "helpful") { $talkupation += $user_power; }

Last edited by stevej; 02-24-2009 at 09:31 PM..
stevej is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-24-2009, 09:41 PM Re: Dynamic Meta Tag
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
I suppose you can fix using eval(), but that would inherit the defined vars.

Another way, and I don't think this would be efficiant, would be to include the files via CURL so it would return the parsed page.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 02-24-2009, 11:24 PM Re: Dynamic Meta Tag
stevej's Avatar
Professional Multitasker

Posts: 996
Location: Not positive
Trades: 0
Hmmm... okay, I'll look into it. Another thing that I think may be causing problems is that other pages, trying to access this page using the sidebar code, are unable to execute the php used in the <meta> tag. I may be wrong, but it seems possible.

- Steve
__________________
if($stevej == "helpful") { $talkupation += $user_power; }
stevej is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Dynamic Meta Tag
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14245 seconds with 12 queries