First time here? Check out the FAQ!
2

How do we include "external" templates in our custom skin?

Hi

We've created a custom skin and we're trying to base our skin on templates used elsewhere on our website ie those present in TEMPLATE_DIRS. Is this a bad idea?

It looks like askbot is only looking in the skins directory for templates as it can't find templates in our application. Looking at the SkinEnvironment class in skins/loaders.py, _get_loaders() creates file system loaders for the custom skin directory. We can modify this to append TEMPLATE_DIRS to the loaders and it seems to work. Is there a better way to do what we want? I guess we could use symbolic links from the skin directory to the application templates directory but that seems a bit of a hack.

I suppose ultimately we're looking to embed askbot so that it looks like any of the other pages on our website so tell us if we're going about this the wrong way.

Martin Burchell's avatar
41
Martin Burchell
asked 2011-06-14 11:18:21 -0500
edit flag offensive 0 remove flag close merge delete

Comments

TEMPLATE_DIRS are not looked into in askbot, because the idea is to support switchable skins, where skin has a name, contains templates and media.
Evgeny's avatar Evgeny (2011-06-14 12:02:39 -0500) edit
Just tested the ASKBOT_EXTRA_SKINS_DIR setup. Worked for me, please take a look at the doc in my answer, I will be happy to clarify anything that brings questions.
Evgeny's avatar Evgeny (2011-06-14 12:23:17 -0500) edit
add a comment see more comments

3 Answers

1
Martin Burchell's avatar
41
Martin Burchell
answered 2011-11-15 05:00:46 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
0

Please take a look at this document, and please ask if anything is not clear

google

Roland's avatar
1
Roland
answered 2011-11-29 22:43:36 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
0

Please take a look at this document, and please ask if anything is not clear (it was written just two days ago, and still is a bit raw).

http://askbot.org/doc/customizing-skin-in-askbot.html

You'll need to specify ASKBOT_EXTRA_SKINS_DIR and place the custom skin there.

Evgeny's avatar
13.2k
Evgeny
answered 2011-06-14 12:01:10 -0500
edit flag offensive 0 remove flag delete link

Comments

Hi Evgeny. Thanks for your answer. We are using ASKBOT_EXTRA_SKINS_DIR and have put the custom skin in there. But we want our skin to be based on templates that exist elsewhere in our application and don't want to have to place copies of them in our custom skins directory.
Martin Burchell's avatar Martin Burchell (2011-06-15 03:53:11 -0500) edit
I see, maybe there is a way to reconcile the differences in the skin approach and the traditional method. Maybe the way you suggested - by appending TEMPLATE_DIRS inside the skin loader... will need to look.
Evgeny's avatar Evgeny (2011-06-15 04:08:30 -0500) edit
Thanks. I think we're going to hit another problem because we're not using jinja2 for our templates so it might be that we'll end up having to replicate modified versions of our templates in our custom skin directory after all. Either that or fix our templates to be compatible with jinja2 but that will be a lot of work.
Martin Burchell's avatar Martin Burchell (2011-06-15 05:50:40 -0500) edit
Yes, this is an issue, bridge template tags would be needed to connect django and jinja2 templates properly. In askbot there is a template tag "include_jinja", that includes contents of jinja template into the django template, but it had limited testing so far. For a full suite we'd need extends_django, extends_jinja2 and include_django, especially I think "extends" type tags are important. I've seen 5-fold speedup of rendering across the board when switched. One gotcha with debugging jinja2 templates - you must have DEBUG=True and TEMLPATE_DEBUG = False.
Evgeny's avatar Evgeny (2011-06-15 12:55:29 -0500) edit
the tag should be called include_jinja2, I'll rename it.
Evgeny's avatar Evgeny (2011-06-15 12:56:09 -0500) edit
add a comment see more comments