Solved

Porting a site into a template

Posted on 2004-04-19
4
177 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
XSLT 5 36
PHP echo implode with escape string syntax 19 60
Collapseable list of URLs. 10 99
File names with & character 6 59
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

772 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

11 Experts available now in Live!

Get 1:1 Help Now