Difference between revisions of "Dynamic Template System"
(Redirected page to API:EPrints/Apache/Template)
|Line 1:||Line 1:|
Latest revision as of 15:58, 16 April 2012
EPrints 2 generated static pages as .html files, by filling in the blanks in the template.
EPrints 3 still does this and writes out .html files but THESE ARE NOT USED unless you choose to turn dynamic templates off.
Dynamic templates mean that some part of the template can change depending on other factors. This is used to show the "you are now logged in as ...." section in the header. You could also use it to show other information (last 3 eprints added, the date and time, etc.). If you do add the last 3 items, make sure it's not doing the search on every page - cache it in a file!
The dynamic template system writes each part of the page out into a separate file. eg. index.title, index.page etc. These are then combined into the template to print the page. This is pretty fast as it does not use the XML library but just concatinates strings. The only XML library bit is the dynamic part, the "now logged in as" section.
index.title.textonly is the version of the title with any markup removed, so that it can safely be used in the title tag in the head of the document.
The .html file is only used if you turn dynamic templates off. In theory this would speed up serving these pages.
to disable the creation of the unused .html file
(someone asked for how to do this)
In perl_lib/EPrints/Session.pm find write_static_page and add:
my $html_file = $filebase.".html"; $self->prepare_page( $parts, page_id=>$page_id ); $self->page_to_file( $html_file, $wrote_files ); }
This is untested!