Forum Moderators: coopster

Message Too Old, No Replies

Need to copy text from one part of page to another

Turning a 3000 page site from HTML to PHP

         

sauce

6:04 pm on Sep 7, 2005 (gmt 0)

10+ Year Member



Hi... I've been slowly migrating an old site from HTML to PHP. It has been great so far but I hit a road block on one thing and I figured the brilliant minds here could help. This site isn't in a database because its 3000 pages of HTML now and we figured we can do work arounds to make it look right. We are starting a database for future data though...

Here is the problem I've ran into...

On every page we added bread crumb ex:

Home > Section > Topic Name

Each section has like 600 pages in it... while we can do a template per section we still have to change the Topic Name on all the pages bread crumbs... The actual topic name is in the page title though ex:

Topic Name - Domainname.com

Is the page title for everypage...

So my question is... is there a way in php or a workaround where I can somehow take the topic name in the title and call/paste in the appropriate place in the bread crumb?

Any ideas would be great. thx.

Sauce

chriswragg

6:49 pm on Sep 7, 2005 (gmt 0)

10+ Year Member



I believe the function you need is ereg [php.net]

You can use a Regular Expression (Reg Exp) the match a pattern in the title.

<?
$data = file_get_contents($_SERVER['SCRIPT_FILENAME']);
if (ereg ("<title>[A-Za-z0-9[:space:]]*", $data, $regs)) {
$topic = str_replace("<title>","",$regs[0]);
} else {
$topic = "Name if script fails";
}
?>

The only problem with this method is that the PHP would have to parse another copy of the file, which may slow page loading down.

Just a suggestion though.

Chris

jd01

8:11 pm on Sep 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could also store the title in a variable (use find & replace), echo the title at the top of the page, and explode it for your bread crumb...

$title="Your Title - domain.com";
echo $title;

$crumb=explode("-",$title); // this will break the title up at the - use " " if you want individual words.

echo $crumb[0];

Should give you an idea.

Justin