I'm wondering if there is a way to generate a site index that displays page titles instead of the full url. I'd like to provide a page that lists a site index in such a format. I have a php site with over 300 pages. Is there a tool out there for this? I already reset the default sitemap to TRUE - using Dreamweaver CS5.5, but the map view says I have to specify the homepage?? What do the experts suggest here?
Many thanks - I always value the input from this forum.
Easy. Create a PHP function file_get_contents and pass the URL of the page you'd like to grab the title for.
Do a regular expression match for <title></title> and grab the contents.
Echo it in your HTML.
Here's a code you can use:
<?php
function returnTitle($Url){
$str = file_get_contents($Url);
if(strlen($str)>0){
preg_match("/\<title\>(.*)\<\/title\>/",$str,$title);
return $title[1];
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Title generator</title>
</head>
<body>
<?php echo returnTitle("http://www.google.com/");?><br>
<?php echo returnTitle("http://www.adobe.com/");?><br>
<?php echo returnTitle("http://www.microsoft.com/");?><br>
<?php echo returnTitle("http://www.apple.com/");?><br>
<?php echo returnTitle("http://www.forums.adobe.com/");?><br>
<?php echo returnTitle("http://forums.adobe.com/message/4917208#4917208");?>
<!-- Add more (as many as you'd like!) URLs here-->
</body>
</html>
Name the file .php and run it from MAMP/ WAMP or on a webserver.
-ST
Thank you! I'm staring at this trying to decipher and have it make sense. I want to generate a list of text links that I will paste into a page for users to navigate through if they choose to. I'm not quite clear what you are saying here. Could you insert http://yoursite.com wherever I am suppose to change the code you have here? This is not for uploading to google, etc. I've done that already. I just need a list of page titles.
Thanks again!!
<?php echo returnTitle("http://www.google.com/");?><br>
<?php echo returnTitle("http://www.adobe.com/");?><br>
<?php echo returnTitle("http://www.microsoft.com/");?><br>
<?php echo returnTitle("http://www.apple.com/");?><br>
<?php echo returnTitle("http://www.forums.adobe.com/");?><br>
<?php echo returnTitle("http://forums.adobe.com/message/4917208#4917208");?>
Change the URL's within the quotes to whatever pages you want.
If you want them to be hyperlinked, change this:
<?php echo returnTitle("http://www.google.com/");?>
to this:
<a href="http://www.yoursite.com"><?php echo returnTitle("http://www.yoursite.com");?></a>
This will grab the page title of yoursite.com and link that to yoursite.com, displaying the page title of pagetitle.com for the text link.
-ST
North America
Europe, Middle East and Africa
Asia Pacific