mojodaddy has asked for the wisdom of the Perl Monks concerning the following question:

I'm in the midst of putting together a web site using the template toolkit where the idea was to have the dynamic data reside in a mysql database and create pages on the fly via the template.

Unfortunately I may need a reality check here as I am on a shared host that provides limited perl modules (Template.pm not being one of them) and where I don't have shell access!

A dawning horror crept over me as I saw myself creating thousands upon thousands of pages here at home and then uploading them into directories on the shared host! To say nothing of repeating this process every time I make a change to the template!

Is that indeed what my future holds, or is there some hope for me?

Replies are listed 'Best First'.
Re: Templating on a shared host?
by Errto (Vicar) on Apr 30, 2007 at 03:09 UTC
    Have a look at the tutorial Installing Modules on a Web Server. I can't promise that this will work with Template Toolkit specifically, not having tried it, but it seems worth a shot.
Re: Templating on a shared host?
by swares (Monk) on Apr 30, 2007 at 03:14 UTC

    I assuming you have a home dir on that host and you can upload files to it.

    If you are so lucky as to have access to a system built like the system your provider uses... OS and Perl version at least.

    You could do a local install of the Perl modules you need on that system and upload the library directories and files that are created to your server. Then add that library path in your Perl scripts.

    See this node if you need to know how to install Perl libs in a non default location. http://www.perlmonks.org/?node_id=128077#permission

Re: Templating on a shared host?
by rodion (Chaplain) on Apr 30, 2007 at 05:01 UTC
    We need to know what you can and can't do on the shared host. Errto has assumed that you yourself can install modules on this server. Others may assume you can get the sysadmin of the server to install a module or two. swares assumes you have a home directory and he points to some good documentation on how to use it.

    From what you said, there is some directory that you can upload files to. If you don't have a home directory, but can create sub-directories, then you can create a directory "yourlib" to use in an analagous way to the '/usr/home/your_home_dir/lib/' directory in the guide that swares refered you to.

    If you can't create directories, and you can't get the sysadmin to install modules, or create the directories you need, then you may be stuck. I don't know if Template::Toolkit can run with just Toolkit.pm in the local directory, using "use lib './';", but that's easy enough for you to try on the server.

      First of all, I appreciate everyone's responses. : )

      To give a bit more detail, I don't have a /home directory per se, but I can create subdirectories within my designated area on the shared host. So it seems like what's described in the guide should work. They are running Red Hat with perl 5.008, whatever that means -- I assume it means 5.8.* -- and I'm on Ubuntu, with perl 5.8.7; So we'll see. I haven't experimented yet, but I'm feeling a bit reassured. My initial searches were only turning up solutions that involved some kind of telnet or SSH connection, so I started to worry...

      In any case, I'm encouraged by isync's reminder that, as always, TIMTOWTDI.

      By the way, ++ everyone for not telling me to get a new hosting provider!

Re: Templating on a shared host?
by merlyn (Sage) on Apr 30, 2007 at 10:51 UTC
    Do you actually need run-time templating, or can you get away with "compile-time" templating? For example, nearly all of the pages of stonehenge.com are actually static, even though I'm generating them all at runtime (hey, I got cycles to spare). As in, I could have used ttree instead of Template directly. Maybe you can do the same?
      Thanks -- I hadn't thought of just using ttree. I should also confess that I don't know whether I need compile-time or run-time templating, as I'm not totally clear on the difference... : )

      In the short term, though, I've been obliged to front-burner a different project; but in a way that's OK because I realized that I'm not too clear on something pretty important: namely, the mechanism whereby a user's click tells the script what page to generate! In other words, I realized that if there are let's say 20,000 separate "chunks" of dynamic data sitting in a database, each of which can be slotted into the template to form one "page," I really don't know how to write the part of the script that takes a user's input selection and then generates that page and only that page. Pretty basic, huh? It's probably just a case of assigning each one a name, like 1.html, 2.html, etc., on up to 20000.html, and then creating my links accordingly. But what if the links themselves have to be created dynamically?

      I'm sure I'll be putting some miles on the Super Search engine when it comes time to figure that one out...

Re: Templating on a shared host?
by isync (Hermit) on Apr 30, 2007 at 07:04 UTC
    I don't know about the complexity of your task, but you could revert to writing your own small templating engine using a regex to replace occurences of tags in your templates with data from your scripts. Combined with a simple caching algorithm it might become quite a fast and lightweight solution.