> 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.
The layout also include a <body> section, does this mean that in my custom
view I shouldn't have another <body> section such that I should just write
all the custom html content without <body></body> tags?
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.
Another thought, can I add page-specific files for the view in the
corresponding controller action, e.g.
def myaction():
response.files.append(URL('static','css/page_specific_css_1.css'))
response.files.append(URL('static','css/page_specific_css_2.css'))
# rest of the action
...
Would this be enough? If so, how does this compare with the two options
you've proposed below?
Regarding my other question about Recaptcha support, how should I embed and
customize it in my custom view? Thanks very much!
On Saturday, July 7, 2012 11:48:05 PM UTC-4, Anthony wrote:
>
> 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
>