开发者

How to make multiple web2py apps use the same layout.html?

I have three applications, but I want them to use the same layout.html and css. Is there any way to achieve this?

EDIT:

I put the static folder and layout.html etc in /common/ under the web2py root.

Here's what I did in the model:

import os
global web2py_path
web2py_path = os.environ.get('web2py_path', os.getcwd())
session.layout_path = web2py_path + '/commo开发者_开发问答n/layout.html'
print 'session.layout_path = ' + session.layout_path

Then in the views:

{{extend session.layout_path}}

EDIT 2:

Regarding the comment below about compiling, I decided to put the 'common' folder into '/applications/' and place the static folder (css, images) inside the 'common' folder like a regular app. I then placed the layout.html into the root of 'common'. Then from another app's view, I used:

{{extend '../../common/layout.html'}}

Which referenced the layout.html from the common app. This layout.html file then referenced the files in the static folder within 'common' using:

{{=URL('common','static','css','style.css')}}

As you would for a regular application.


in the root of your web2py folder create a new folder called 'templates'

/web2py/templates

put your layout.html there.

now in your views do:

{{extend 'path/to/web2py/templates/layout.html'}}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜