473,398 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How to pull existing Title tag into the body of the document as textonly

I need to be able to pull the current <Title> tag from the header into
the body of the html page. We started coding this with php, and we
were able to get it working. However the entire page is being parsed
and really bogging down the system and the pages load very slowly.
(the system is Dual P4 2.4, 1GB ram, Redhat 9.0)
To fix this we decided to just use javascript, which worked great.
Text loaded immediately. However, search engines will not process the
javascript, thus this text will not be available in the document to be
scanned.
Does anyone have a way to pull a title tag from a document and display
its content as text only within a document, Without loading down the
system? When we tried it, it took the pages at least 5 times longer to
load than without the code.

Any feedback at all would be greatly appreciated. Thanks very much.
Jul 17 '05 #1
11 2029
*** Mike wrote/escribió (Thu, 05 Aug 2004 05:08:49 GMT):
Does anyone have a way to pull a title tag from a document and display
its content as text only within a document, Without loading down the
system? When we tried it, it took the pages at least 5 times longer to
load than without the code.


I'm not sure of your exact requirements but the easiest solutions seems to
use a variable:

<?
$title='Foo';
?>
<html>
<head>
<title><?=$title?></title>
</head>
<body>
<p>This page is "<?=$title?>".</p>
</body>
</html>

--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #2
"Mike" <pl****@spam-me-not.com> wrote in message
news:Bh*******************@twister.socal.rr.com...
I need to be able to pull the current <Title> tag from the header into
the body of the html page. We started coding this with php, and we
were able to get it working. However the entire page is being parsed
and really bogging down the system and the pages load very slowly.
(the system is Dual P4 2.4, 1GB ram, Redhat 9.0)
To fix this we decided to just use javascript, which worked great.
Text loaded immediately. However, search engines will not process the
javascript, thus this text will not be available in the document to be
scanned.
Does anyone have a way to pull a title tag from a document and display
its content as text only within a document, Without loading down the
system? When we tried it, it took the pages at least 5 times longer to
load than without the code.

Any feedback at all would be greatly appreciated. Thanks very much.


Can you describe the situation in greater details? Are you saying you have
many static HTML files that need adjustment, or are the pages generated
dynamically?

And what exactly do you mean by parsing the page? Finding a text string
within a file is absolute cakewalk. It shouldn't bog down the system to such
a degree.
Jul 17 '05 #3
WE have 1000s of static pages. We need to read the title from each
page and display that on the page.

We are using the following php function which causes extremely slow
page load times..

function get_title () {

$tempHost = $_SERVER['HTTP_HOST'];
$tempPath = $_SERVER['PHP_SELF'];
$tempQuery = $_SERVER['QUERY_STRING'];
$loc = "http://" . $tempHost . $tempPath . $tempQuery;

$open=fopen("$loc","r");
while(!feof($open))
{

$line=fgets($open,255);
$string = $line;
while ( ereg( '<title>([^<]*)</title>(.*)', $string, $regs ) )
{
$string = $regs[2];
}

}

return $regs[1];

}

"Chung Leong" <ch***********@hotmail.com> wrote in message news:<oJ********************@comcast.com>...
"Mike" <pl****@spam-me-not.com> wrote in message
news:Bh*******************@twister.socal.rr.com...
I need to be able to pull the current <Title> tag from the header into
the body of the html page. We started coding this with php, and we
were able to get it working. However the entire page is being parsed
and really bogging down the system and the pages load very slowly.
(the system is Dual P4 2.4, 1GB ram, Redhat 9.0)
To fix this we decided to just use javascript, which worked great.
Text loaded immediately. However, search engines will not process the
javascript, thus this text will not be available in the document to be
scanned.
Does anyone have a way to pull a title tag from a document and display
its content as text only within a document, Without loading down the
system? When we tried it, it took the pages at least 5 times longer to
load than without the code.

Any feedback at all would be greatly appreciated. Thanks very much.


Can you describe the situation in greater details? Are you saying you have
many static HTML files that need adjustment, or are the pages generated
dynamically?

And what exactly do you mean by parsing the page? Finding a text string
within a file is absolute cakewalk. It shouldn't bog down the system to such
a degree.

Jul 17 '05 #4
WE have 1000s of static HTML pages to update. We need to read the
page title and display it within the page.

I am using the following function which causes page load times of
1min+

function get_title () {

$tempHost = $_SERVER['HTTP_HOST'];
$tempPath = $_SERVER['PHP_SELF'];
$tempQuery = $_SERVER['QUERY_STRING'];
$loc = "http://" . $tempHost . $tempPath . $tempQuery;

$open=fopen("$loc","r");
while(!feof($open))
{

$line=fgets($open,255);
$string = $line;
while ( ereg( '<title>([^<]*)</title>(.*)', $string, $regs ) )
{
$string = $regs[2];
}

}

return $regs[1];

}

"Chung Leong" <ch***********@hotmail.com> wrote in message news:<oJ********************@comcast.com>...
"Mike" <pl****@spam-me-not.com> wrote in message
news:Bh*******************@twister.socal.rr.com...
I need to be able to pull the current <Title> tag from the header into
the body of the html page. We started coding this with php, and we
were able to get it working. However the entire page is being parsed
and really bogging down the system and the pages load very slowly.
(the system is Dual P4 2.4, 1GB ram, Redhat 9.0)
To fix this we decided to just use javascript, which worked great.
Text loaded immediately. However, search engines will not process the
javascript, thus this text will not be available in the document to be
scanned.
Does anyone have a way to pull a title tag from a document and display
its content as text only within a document, Without loading down the
system? When we tried it, it took the pages at least 5 times longer to
load than without the code.

Any feedback at all would be greatly appreciated. Thanks very much.


Can you describe the situation in greater details? Are you saying you have
many static HTML files that need adjustment, or are the pages generated
dynamically?

And what exactly do you mean by parsing the page? Finding a text string
within a file is absolute cakewalk. It shouldn't bog down the system to such
a degree.

Jul 17 '05 #5
beau <be**@customautotrim.com> wrote:
WE have 1000s of static pages. We need to read the title from each
page and display that on the page.
Why!
We are using the following php function which causes extremely slow
page load times..
If the pages are static you should create a static list with titles.
function get_title () {

$tempHost = $_SERVER['HTTP_HOST'];
$tempPath = $_SERVER['PHP_SELF'];
$tempQuery = $_SERVER['QUERY_STRING'];
$loc = "http://" . $tempHost . $tempPath . $tempQuery;

$open=fopen("$loc","r");
while(!feof($open))
{ .... }

return $regs[1];

}


Definition of recursive: see recursive.

--

Daniel Tryba

Jul 17 '05 #6
We need to pull that info and display it as text. We want to do it with
php if it is possible. I dont want to have to build a database for the
same info to pull it that way, there has to be an efficient way to do it
right on the page that isists as it is.
Thanks for your help.
mike


Daniel Tryba wrote:
beau <be**@customautotrim.com> wrote:
WE have 1000s of static pages. We need to read the title from each
page and display that on the page.

Why!

We are using the following php function which causes extremely slow
page load times..

If the pages are static you should create a static list with titles.

function get_title () {

$tempHost = $_SERVER['HTTP_HOST'];
$tempPath = $_SERVER['PHP_SELF'];
$tempQuery = $_SERVER['QUERY_STRING'];
$loc = "http://" . $tempHost . $tempPath . $tempQuery;

$open=fopen("$loc","r");
while(!feof($open))
{


...
}

return $regs[1];

}

Definition of recursive: see recursive.

Jul 17 '05 #7
We need to pull that info and display it as text. We want to do it with
php if it is possible. I dont want to have to build a database for the
same info to pull it that way, there has to be an efficient way to do it
right on the page that exists as it is.
Thanks for your help.
mike


Daniel Tryba wrote:
beau <be**@customautotrim.com> wrote:
WE have 1000s of static pages. We need to read the title from each
page and display that on the page.

Why!

We are using the following php function which causes extremely slow
page load times..

If the pages are static you should create a static list with titles.

function get_title () {

$tempHost = $_SERVER['HTTP_HOST'];
$tempPath = $_SERVER['PHP_SELF'];
$tempQuery = $_SERVER['QUERY_STRING'];
$loc = "http://" . $tempHost . $tempPath . $tempQuery;

$open=fopen("$loc","r");
while(!feof($open))
{


...
}

return $regs[1];

}

Definition of recursive: see recursive.

Jul 17 '05 #8
"beau" <be**@customautotrim.com> wrote in message
news:3d**************************@posting.google.c om...
WE have 1000s of static HTML pages to update. We need to read the
page title and display it within the page.

I am using the following function which causes page load times of
1min+

function get_title () {

$tempHost = $_SERVER['HTTP_HOST'];
$tempPath = $_SERVER['PHP_SELF'];
$tempQuery = $_SERVER['QUERY_STRING'];
$loc = "http://" . $tempHost . $tempPath . $tempQuery;

$open=fopen("$loc","r");
while(!feof($open))
{

$line=fgets($open,255);
$string = $line;
while ( ereg( '<title>([^<]*)</title>(.*)', $string, $regs ) )
{
$string = $regs[2];
}

}

return $regs[1];

}


The main problem here is that you're pulling the text through HTTP. You will
see significant improvement in your script by fopen()ing the file through
the file system.

Perhaps even more damaging to performance is the fact that you're calling
ereg() on each line of a file. ereg() known to be less efficient than PCRE.
And compiling a regular pression takes time.
Jul 17 '05 #9
Mike <pl****@spam-me-not.com> wrote:
We need to pull that info and display it as text. We want to do it with
php if it is possible. I dont want to have to build a database for the
same info to pull it that way, there has to be an efficient way to do it
right on the page that exists as it is.


If you need this there is something definitly flawwed in your setup...
but you can get the already generated output from a script with a ob
handler: http://nl3.php.net/manual/en/ref.outcontrol.php

--

Daniel Tryba

Jul 17 '05 #10
be**@customautotrim.com (beau) wrote in message news:<3d**************************@posting.google. com>...
WE have 1000s of static pages. We need to read the title from each
page and display that on the page.

We are using the following php function which causes extremely slow
page load times..

function get_title () {

$tempHost = $_SERVER['HTTP_HOST'];
$tempPath = $_SERVER['PHP_SELF'];
$tempQuery = $_SERVER['QUERY_STRING'];
$loc = "http://" . $tempHost . $tempPath . $tempQuery;

$open=fopen("$loc","r");
while(!feof($open))
{

$line=fgets($open,255);
$string = $line;
while ( ereg( '<title>([^<]*)</title>(.*)', $string, $regs ) )
{
$string = $regs[2];
}

}

return $regs[1];

}


If I understand well what you mean, you are trying to get a pretty
static TOC html page. Why don't you just implement some very basic
caching system? (No rocket science implied, really).

Basically, you keep the same script, but crontab it (or use this
windows scheduler thing if you are running Windows), every hour, or
every day, every 10 minutes, depending of how often the <title>'s are
changed.

With some basic modifications, the script, instead of generating the
page on the fly, will generate a static .html page whose speed can't
be beaten.

Or am I misunderstanding something?

HTH,
JFLac
Jul 17 '05 #11

"Chung Leong" <ch***********@hotmail.com> wrote in message
news:5M********************@comcast.com...
"beau" <be**@customautotrim.com> wrote in message
news:3d**************************@posting.google.c om...
WE have 1000s of static HTML pages to update. We need to read the
page title and display it within the page.

I am using the following function which causes page load times of
1min+

function get_title () {

$tempHost = $_SERVER['HTTP_HOST'];
$tempPath = $_SERVER['PHP_SELF'];
$tempQuery = $_SERVER['QUERY_STRING'];
$loc = "http://" . $tempHost . $tempPath . $tempQuery;

$open=fopen("$loc","r");
while(!feof($open))
{

$line=fgets($open,255);
$string = $line;
while ( ereg( '<title>([^<]*)</title>(.*)', $string, $regs ) )
{
$string = $regs[2];
}

}

return $regs[1];

}
The main problem here is that you're pulling the text through HTTP. You

will see significant improvement in your script by fopen()ing the file through
the file system.

Perhaps even more damaging to performance is the fact that you're calling
ereg() on each line of a file. ereg() known to be less efficient than PCRE. And compiling a regular pression takes time.


It seems that my original reply got lost somewhere... the main problem is
not ereg, but the fact that he is not terminating the WHILE loops after the
<title> tag is found. Inserting a BREAK 2; into the inner WHILE loop after
$string = $regs[2]; will fix the big problem. That and a fclose($open); at
the end wouldn't hurt either.

Norm
Jul 17 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sylvie Stone | last post by:
Hi group - I have an html form for that uses username and password to login to a specific area of the website. The "area" the user wants to go to is based on a pull down menu. Becasue the...
3
by: D. Alvarado | last post by:
Hello, I am trying to find the <TITLE> element of my document. Normally alert(document.title); works just fine, but when this statement is within a page that is a frame in a larger document,...
10
by: Melissa Mussitsch | last post by:
I've done this before while creating a brand new table. But the code below is not working and I keep getting the error: "Internet Explorer cannot open the Internet site ..... Operation aborted" ...
0
by: mnmnm1951 | last post by:
I am working with Sharepoint Services and am trying to add the fileversion Metadata to the Versions.aspx page using the example from the SDK. I have not done much with hashtables but it all looks...
7
by: Andrea | last post by:
Hi there - I'm hoping someone can help me; I've been struggling with this for a few days! :-) I have a webpage that is comprised of many forms containing questions. As the user answers one...
1
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. ...
1
by: kksandeep | last post by:
i am using this three files to uplod file. i got this file from net but i think these have some error. i am new to this field plz help the script i found is some helpful but not too that i need ...
1
by: gbengston | last post by:
Please look at my example, I have a script that pulls the value of one cell and inserts it into an input box in another cell. My problem is that the source cell is itself an input box so when I pull...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.