How to make a good page layout
[edit|delete]web2py controller automatically export some variables to the layout (reponse.title, response.keywords, response.description, response.flash, response.flash, and you can define your own). Here is how you can create your own layout.html file.
- find a page layout that you like
- make sure it released under some open source artistic license
- give a name to it ('layoutsleek001')
- create a folder under static called layoutsleek001 and move all the static files for the layout in there
- save the layout under views as layout_sleel001.html
- edit layoutsleek001.html and use {{=URL(r=request,c='static',f='layoutsleek001/whatever.css')}} to include the static files
- edit layoutsleek001.html and make sure it has the following structure:
layoutsleek001.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="keywords" content="{{=response.keywords}}" />
<meta name="description" content="{{=response.description}}" />
<title>{{=response.title if response.title else request.application)}}</title>
<link href="{{=URL(r=request,c='static',f='style.css')}}" rel="stylesheet" type="text/css"/>
{{include 'web2py_ajax.html'}}
</head>
<body>
<h1>Here goes the header, followed by the menu</h1>
{{if response.menu:}}
<div id="menu">
<ul>
{{for _name,_active,_link in response.menu:}}
<li><a href="{{=_link}}" class="{{='active' if _active else 'inactive'}}">{{=_name}}</a></li>
{{pass}}
</ul>
</div>
{{pass}}
<h1>Here goes the flash message</h1>
{{if response.flash:}}<div id="flash">{{=response.flash}}</div>{{pass}}
<h1>Here goes the main (the view that extends this one)</h1>
{{include}}
<h1>... and here the footer</h1>
</body>
</html>
Comments
Pystar on 2008-04-28 03:43:17 says
Thanks a million, just what i have been looking for, now i am trully hooked onto web2py
[inappropriate?]
Thanks a million, just what i have been looking for, now i am trully hooked onto web2py
[inappropriate?]