Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

Porting a site into a template

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
tbconrad
Asked:
tbconrad
  • 2
1 Solution
 
dorwardCommented:
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
 
joespCommented:
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
 
dorwardCommented:
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
 
hendridmCommented:
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now