Solved

Porting a site into a template

Posted on 2004-04-19
4
180 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Programatically edit Web.config 8 37
File names with & character 6 84
I starting with php 12 137
JQuery tracking event. 3 79
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

820 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