doc/tutorials/advanced/part04_ui-base.rst
changeset 12406 57b29c6f8036
parent 12405 99e150b6a876
child 12407 d4e0af0b5ad7
equal deleted inserted replaced
12405:99e150b6a876 12406:57b29c6f8036
   102     def registration_callback(vreg):
   102     def registration_callback(vreg):
   103         vreg.register_all(globals().values(), __name__, (IndexView,))
   103         vreg.register_all(globals().values(), __name__, (IndexView,))
   104         vreg.register_and_replace(IndexView, startup.IndexView)
   104         vreg.register_and_replace(IndexView, startup.IndexView)
   105 
   105 
   106 As you can see, we override the default index view found in
   106 As you can see, we override the default index view found in
   107 `cubicweb.web.views.startup`, geting back nothing but its identifier and selector
   107 `cubicweb.web.views.startup`, getting back nothing but its identifier and selector
   108 since we override the top level view's `call` method.
   108 since we override the top level view's `call` method.
   109 
   109 
   110 .. Note::
   110 .. Note::
   111 
   111 
   112   in that case, we want our index view to **replace** the existing one. To do so
   112   in that case, we want our index view to **replace** the existing one. To do so
   113   we've to implements the `registration_callback` function, in which we tell to
   113   we've to implements the `registration_callback` function, in which we tell to
   114   register everything in the module *but* our IndexView, then we register it
   114   register everything in the module *but* our IndexView, then we register it
   115   instead of the former index view.
   115   instead of the former index view.
   116 
   116 
   117 Also, we added a title that tries to make it more evident that the visitor is
   117 Also, we added a title that tries to make it more evident that the visitor is
   118 authenticated, or not. Hopefuly people will get it now!
   118 authenticated, or not. Hopefully people will get it now!
   119 
   119 
   120 
   120 
   121 .. figure:: ../../images/tutos-photowebsite_index-before.png
   121 .. figure:: ../../images/tutos-photowebsite_index-before.png
   122    :alt: default index page screenshot
   122    :alt: default index page screenshot
   123 
   123 
   127    :alt: new index page screenshot
   127    :alt: new index page screenshot
   128 
   128 
   129    Our simpler, less intimidating, index page (still translated in french)
   129    Our simpler, less intimidating, index page (still translated in french)
   130 
   130 
   131 
   131 
   132 Step 3: more navigation improvments
   132 Step 3: more navigation improvements
   133 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   133 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   134 
   134 
   135 There are still a few problems I want to solve...
   135 There are still a few problems I want to solve...
   136 
   136 
   137 * Images in a folder are displayed in a somewhat random order. I would like to
   137 * Images in a folder are displayed in a somewhat random order. I would like to
   138   have them ordered by file's name (which will usually, inside a given folder,
   138   have them ordered by file's name (which will usually, inside a given folder,
   157         fetch_attrs, cw_fetch_order = fetch_config(['data_name', 'title'])
   157         fetch_attrs, cw_fetch_order = fetch_config(['data_name', 'title'])
   158 
   158 
   159 
   159 
   160 By default, `fetch_config` will return a `cw_fetch_order` method that will order
   160 By default, `fetch_config` will return a `cw_fetch_order` method that will order
   161 on the first attribute in the list. So, we could expect to get files ordered by
   161 on the first attribute in the list. So, we could expect to get files ordered by
   162 their name. But we don't.  What's up doc ?
   162 their name. But we don't. What's up doc?
   163 
   163 
   164 The problem is that files are related to folder using the `filed_under` relation.
   164 The problem is that files are related to folder using the `filed_under` relation.
   165 And that relation is ambiguous, eg it can lead to `File` entities, but also to
   165 And that relation is ambiguous, eg it can lead to `File` entities, but also to
   166 `Folder` entities. In such case, since both entity types doesn't share the
   166 `Folder` entities. In such case, since both entity types doesn't share the
   167 attribute on which we want to sort, we'll get linked entities sorted on a common
   167 attribute on which we want to sort, we'll get linked entities sorted on a common