Adding some variables from config.ini
Samuel Kay <samuel-kay <at> 401kay.fr>
2012-01-02 15:47:05 GMT
Hi,
I wanted to use the same template to create three different pages. One
with the news of the 5 last days, the second with the news of the 21
last days and the last one with the news of the 90 last days. I did it
by copying the template and adding a section :
[examples/fancy/index_5j.html.tmpl]
days_per_page = 5
[examples/fancy/index_21j.html.tmpl]
days_per_page = 21
But, I also wanted a link to the RSS file and to the ATOM file. So, I
had to edit each html template to link it to the right file. I would
rather had use some variable to do that and keep template untouched.
In the config.ini file, you can add variables for channel. You can also
configure options for the templates. So I thought there should be a way
to add variable for templates.
Channel variables are prefixed by "channel_", so in my code, those for
template are prefixed by "file_".
If there was already a way to do that, please tell me !
Otherwise, I give you the diff. I have to warn you, it is my first code
in python.
Sincerely yours,
Samuel Kay
294c294,298
<
---
>
> if self.config.has_section(template_file):
> for option in self.config.options(template_file):
> tp.set("file_" + option, self.config.get(template_file, option) )
>
--
--
devel mailing list
devel <at> lists.planetplanet.org
http://lists.planetplanet.org/mailman/listinfo/devel