>
> 1. I want to utilize 'layout.html' to some extent such that it stores some 
> common css files for the rest of the view pages. Kinda like a shared base 
> template, and I want to add page-specific css (or js) files on individual 
> html view page. Is it as simple as including:
>
> {{extend layout.html}}
> <head>
>    <link href="css/page_specific_css_1.css" rel="stylesheet">
>    <link href="css/page_specific_css_2.css" rel="stylesheet">
> </head>
>
> in the <head> section of a html view page? By doing this, do we append the 
> above two css files to the list of the files in response.files (which is 
> already set in 'layout.html')
>

No, because the layout already includes a <head> section. The content of 
the view gets inserted in the layout.html file at the point of the 
{{include}}, which presumably is not in the head. Instead, you have a 
couple options. First, you could add the files to response.files before 
extending the layout:

{{response.files.extend([URL('static', 'css/css_1.css'), URL('static', 
'css/css_2.css')])}}
{{extend 'layout.html'}}

Then, if your layout includes web2py_ajax.html, it will link those css 
files in the head. Alternatively, you could create a block in the head of 
layout.html, and then customize the content of that block in your page view 
-- see http://web2py.com/books/default/chapter/29/5#Blocks-in-views.

Anthony 

Reply via email to