Changes between Version 2 and Version 3 of DeveloperGuidelines/Templates/CustomPages


Ignore:
Timestamp:
06/24/12 12:27:20 (9 years ago)
Author:
Fran Boon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Templates/CustomPages

    v2 v3  
    3333& then run the {{{index()}}} function inside there instead.
    3434
    35 Note: you must have an {{{__init__.py}}} in your template folder for this to work (it can be empty).
    36 
     35Notes:
     36* You must have an {{{__init__.py}}} in your template folder for this to work (it can be empty).
     37* Unlike normal controllers, the scope this function is run in will start empty, so import what you need
     38* If a custom View template is passed in from the Template folder then this will need to be provided as a File not a String to work in compiled mode:
     39{{{
     40import os
     41from gluon import current
     42from gluon.http import HTTP
     43response = current.response
     44path = os.path.join(current.request.folder, "private", "templates",
     45                    response.s3.theme, "views", "index.html")
     46try:
     47   # Pass view as file not str to work in compiled mode
     48   response.view = open(path, "rb")
     49except IOError:
     50   raise HTTP("404", "Unable to open Custom View: %s" % path)
     51}}}
    3752== Custom Page ==
    3853