[Zope] Skins - a few questions (LONG)
Shalabh Chaturvedi
shalabh@pspl.co.in
Wed, 22 Dec 1999 17:35:07 +0530
maxm wrote:
> Hi
>
> I, like a lot of other people have fallen in love with Zope, and I can
see
> the benefits of it all. Therefore I will start working in this
enviroment
> from now on.
>
> One of the things I would really like is the ability to make skins. A
way to
> make different layouts that can be changed at a whim. Very useable for
> instance when somebody wants to browse a site with the Lynx browser,
and
> somebody else wants to use the Acme 17.6 browser, or you simply want
to use
> the same logic to drive sites with different layouts. A products like
> squishdot would be a prime candidate for this.
>
> The skin could be choosen on a per session base or dependening on what
> browser is used or saved in a user preference setting or all of the
above.
>
> I have been working with IIS/ASP and Apache/PHP for a while and have
made
> various skin systems in these enviroments.
I'd say your ideas fit perfectly into the Zope framework.
> the general idea is that i make some templates into which I insert the
> content and then call these templates as functions:
> <snipped>
> I have also made sites where the pages are saved as html files that I
then
> load and replace some keywords with the correct html via functions.
>
> a simplified example can be seen here in python :
>
> ---
> >!-- Template file shown here here -->
> <html>
> <head>
> <title>Welcome to my site</title>
> </head>
> <body>
> %Content%
> </body>
> </html>
> ---
>
> def DK_Page(content):
> fileinput = open(TemplateFilePath + 'Template.htm' , 'r')
> FileContent = fileinput.read()
> fileinput.close()
> return re.sub(r'\%content\%', content, FileContent)
>
> ---------------------------------------------------------------
>
> This is the same principle as the PHP example, but with the layout
> completely seperated. The advantage here is that the page designer can
have
> a whole page to work in, and save it all as an HTML file and only has
to
> remember to put the %title% and %content% and other tags in the
templates.
>
> This is muche healthier for a designer I have found (I work at an
> advertising agency with a lot of traditional Layouters).
>
> Personally i don't like the traditional zope way of doing it with:
>
> <!--#var html_header-->
> content
> <!--#var html_footer-->
>
> As you have to split up a layout that really shouldn't be split. It's
hard
> for designers, a bit cumbersome, and it is errorprone allways having
to
> remember to cut a file in two and then uploading both.
How about this:
---
>!-- Zope version of above Template -->
<html>
<head>
<title>Welcome to my site</title>
</head>
<body>
<dtml-var content>
</body>
</html>
---
It's exactly like you want - it's not mandatory to use standard_header
and footer.
> Furthermore you cannot easily have different users use different skins
this
> way.
>
> I would really like for the designers to be able to put up template
html
> files with a few keyword tags in them. ftp to the ZODB is fine, but a
folder
> in the filesystems would also suffice. A directory/file structure
something
> like this:
> <snipped>
Zope does this out of the box:-
Say the contents are defined in dtml documents called:-
-NewsStuff
-LinksStuff
-GreetingStuff
-MainStuff
All the designer has to do is write an _html_ document and put in these
vars where he wants. Like this:-
-------------
<html>
....
<body>
<b>
<dtml-var GreetingStuff>
</b>
<dtml-var MainStuff>
<h2>News...</h2>
<dtml-var NewsStuff>
Please visit:
<dtml-var LinksStuff>
<body>
</html>
------------
Isn't this what you want?
Zope probably is closer to this concept that PHP.
> 1)
>
> To get started I have made a dtml method called "box" in the root of
my zope
> site that looks like this:
>
> <table spacing=3 border=0 padding=0 width=100%>
> <tr bgcolor=green>
> <td><font size=+1 color=white><b><!--dtml-var
> theTitle--></b></font></td>
> <tr>
> </tr>
> <td><!--dtml-var theContent--></td>
> </tr>
> </table>
>
> How do I call it from a dtml document?
<dtml-var theContent>
> I have tried different things and I cannot seem to succed.
>
> Perhaps I should user an external python method? this would be a lot
more
> like I am used to, but would probably result in bastard dtml.
You dont need externals methods for this (not yet ;-)
> --------------------------------
> 2)
> Is there any other obvious way to do this in Zope? Would it be a waste
of
> time implementing a product like this as it would be easier to ...
I'd do it like I've said above. If you want extra features you can
implement a product, but Zope as is would do most of what you want.
> --------------------------------
Cheers,
Shalabh