Solved

Porting a site into a template

Posted on 2004-04-19
4
179 Views
Last Modified: 2010-04-06
Hey folks,
I have a question about porting an entire site that is not currently connected to a template into a new template.  I am taking over a project from a disgruntled ex-employee who was developing a template for a site of several hundred pages. It appears that his intentions was to take the '<body> all html code here </body>' place it into the template and save the file and move on to the next file. Is there a way to script this function using vbscript, Java Script or XML. If so what would be the most efficient way as there is a deadline a few days off?
0
Comment
Question by:tbconrad
  • 2
4 Comments
 
LVL 17

Expert Comment

by:dorward
ID: 10860854
If you don't mind installing Perl (free) - http://www.activestate.com/Products/ActivePerl/ - this is really easy if you use a combination of:

File::Find to work on lots and lots of files in sequence: http://search.cpan.org/~lbrocard/perl5.005_04/lib/File/Find.pm
and
HTML::TreeBuilder to extract the data: http://search.cpan.org/~sburke/HTML-Tree-3.18/lib/HTML/TreeBuilder.pm
and
HTML::Template to put it in the new template: http://search.cpan.org/~samtregar/HTML-Template-2.6/Template.pm

A complete script will probably only be about 15 lines to work through all the HTML files in a directory (and subdirs).
0
 
LVL 1

Expert Comment

by:joesp
ID: 10886023
you need to choose a server-side programming solution to use templates AFAIK.  The common perl one is html::template and templatetoolkit.  See templatetoolkit.org for that.  You would need to learn/know perl.

php has a few template engines.  there is one also built in.  I have had some success with smarty and vlib.  

It erquires a lot of work to convert a site, as every file must be edited.  YOu could use sed for this to speed things up.  I have a sed script which does multiple file editing at

http://www.sirfsup.com/unix/unix_editors/sed/runsed.sh

which uses a file for input (pattern substitutions) like:


http://www.sirfsup.com/unix/unix_editors/sed/sedscr

BTW you need templates
0
 
LVL 17

Expert Comment

by:dorward
ID: 10886480
You don't need to use a server-side programming solution. You can preprocess the source material to generate static files before the web server software reads them. This could be done on the server, or on a development workstation before being uploaded.
0
 
LVL 8

Accepted Solution

by:
hendridm earned 20 total points
ID: 10959493
There are a number of ways to do this, ordered from easiest/cheapest to most difficult/most resource intensive:

1. The most simple way is to use server-side includes (SSI) to include a header and footer.  CSS/XHTML+SSI include makes this fairly simple and elegant.
2. Use a scripting language (PHP, Perl) with some sort of template engine. (ex: http://smarty.php.net)
3. Use a content management system (CMS) that publishes static pages (with template and content merged) to your web server. (ex: http://www.bigmedium.com/).
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Removing Flash from Website 6 65
PHP parse error 7 60
Having Returning  Anonymous Function Access Global Function 7 91
website content maintenance 3 94
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question