Solved

Porting a site into a template

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now