473,396 Members | 1,813 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,396 software developers and data experts.

Template Pages with Parse File

Hey,

I have a lot of common things I want to be included on different pages
(i.e. the page title, the header, some buttons and such, etc.).

So I was thinking of putting things like "*PAGETITLE*" into my html
documents, then having a parse.php file that would replace *PAGETITLE*
with the title of the pages.

So I would structure my links like
"http://www.domain.com/parse.php?link=aboutUs.html". It would read in
aboutUs.html, do a string replacement in the appropriate places, then
output what's left.

But something is giving me the feeling that this is a bad idea.

What do you think?

Thanks
iw****@gmail.com

Sep 10 '05 #1
3 2208
IW****@gmail.com wrote:
So I would structure my links like
"http://www.domain.com/parse.php?link=aboutUs.html". It would read in
aboutUs.html, do a string replacement in the appropriate places, then
output what's left.

But something is giving me the feeling that this is a bad idea.

What do you think?


I agree that this is a bad idea. Even when you thoroughly validate the
contents of the link parameter, it reduces the maintainability of your site.

If you want to change the name of the page, you will have to modify all
references. A better solution would be to use a link like:

http://www.domain.com/parse.php?link=about

This way, it's not important how the template file is called and you can
validate the link parameter easily against a list of valid values.
JW


Sep 10 '05 #2
IW****@gmail.com wrote:
So I would structure my links like
"http://www.domain.com/parse.php?link=aboutUs.html". It would read in
aboutUs.html, do a string replacement in the appropriate places, then
output what's left.


You are essentially replicating, in a primitive fashion, the
functionality of the web server and PHP. File look-up is the job of the
web server. Page processing--that's the reason PHP exists in the first
place.

When you have things that happen in multiple places, think function.
What I typically do is have a file that contains the global interface,
with the HTML enclosed inside functions:

<? function PrintHeader($title = "Default title") { ?>
<html>
<head>
<title><?=$title?></title>
.....
<? } ?>
<? function PrintFooter() { ?>
</body>
</html>
<? } ?>

Then I include the file and call the function in each page:

<? require("global.php"); ?>
<? PrintHeader("About Us"); ?>

[ ... page contents ... ]

<? PrintFooter(); ?>

For a more detailed example, go to www.php.net and click on show source.

Sep 11 '05 #3
thanks

Sep 11 '05 #4

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

Similar topics

2
by: bettyann | last post by:
i am using templates via HTML_Template_IT to create a table from the results of a mysql query. i wanted to change the background image of alternating rows in the table. i thought i could do this...
2
by: littlefitzer | last post by:
Hi, Say for example I want to use the following line in my XSL: <xsl:call-template name="buildText"/> I know I have to have a template defined named buildText. My question is: Is there a way...
8
by: Colin Mc Mahon | last post by:
Hi all, I am currently using a system you are probably familiar with if you have done any templating with vbscript, define a template file with special tokens in it(like ##Content## etc), load...
0
by: Gil | last post by:
Hope this is the right group to post to. I compiled C++ code that ran fine on Windows with VisualStudio 6.0. I then moved the code to Solaris 9 and compiled with g++, but am getting the...
4
by: Brian Barnes | last post by:
I am trying to create a template code behind file for a website which all pages should be inherited from. This base class however, when I try to view the aspx page in Visual studio .NET (2002), it...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
1
by: gio | last post by:
I have a template class with a function that looks like this: template <class Key, int Value, class Tail> struct Parser<Typelist< MakePair<Key, Value>, Tail >, EmptyType> { static...
2
by: rn5a | last post by:
Please have a look at the image at the URL given below: http://rn5a.brinkster.net/Template.gif I would like to use that image as a template for all the ASP pages in a website. Note that though...
6
by: Gaijinco | last post by:
I'm trying to do a template class Node. My node.hpp is: #ifndef _NODE_HPP_ #define _NODE_HPP_ namespace com { namespace mnya { namespace carlos { template <typename T>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.