Forums / Setup & design / Generate file from template

Generate file from template

Author Message

Tobias Persson

Tuesday 28 September 2004 4:54:48 am

I have a small problem that I haven't found a nice solution for yet.

The thing is that I have a tree-menu that is created with javascript and fetched from the database. It works great, but I would like to put the javascripts in a separate .js file instead of having it inside the html-file.

Anyone done something like that before?

The only solution I can think of myself, is to create a .php script that I run via cron that creates the .js file. Is that the way to do it?

/Tobbe

Frederik Holljen

Tuesday 28 September 2004 5:03:22 am

It is a bit unclear to me what you are trying to do (the part about cronjobs confused me). If you have a static javascript and you want to have it inside a .js file you can include the file using something like: <script language="JavaScript" src={"path.to.your.file"|ezdesign}></script>.

Tobias Persson

Tuesday 28 September 2004 5:18:33 am

Well, the javascript is static when the content and folders doesn't change in my site (and that is not too often). But the javascript do change. ie the javascript describes the structure of my site.

What I would like to use is a template-function that writes selected content to a file. In my case to a .js file that I can include with a normal
<script language="JavaScript" src={"path.to.your.file"|ezdesign}></script> later.

Maybe this is a totaly useless function (as it works great as it is now), but it will make the html code of the site cleaner.