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 + '/common/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'}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With