Changes between Version 24 and Version 25 of S3/S3Navigation


Ignore:
Timestamp:
03/05/12 14:01:11 (13 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • S3/S3Navigation

    v24 v25  
    131131
    132132S3NavigationItem provides a number of helper methods for item introspection:
     133
     134Get a sub-item of this item:
     135{{{
     136    sub_item = item[i]
     137}}}
     138
     139Loop over sub-items:
     140{{{
     141    for sub_item in item:
     142        ...
     143}}}
     144
     145Get the root item of the tree:
     146{{{
     147    root_item = item.get_root()
     148}}}
     149
     150Get the path (list of items) from the root item down to this item:
     151{{{
     152    path = item.path()
     153}}}
     154
     155Get all sub-items with certain flags (can also take multiple flags):
     156{{{
     157    enabled_sub_items = item.get_all(enabled=True)
     158}}}
     159
     160Get the first sub-item with certain flags (can also take multiple flags):
     161{{{
     162    first_authorized_and_enabled_sub_item = item.get_first(enabled=True, authorized=True)
     163}}}
     164
     165Get the last sub-item with certain flags (analogous to above):
     166{{{
     167    last_authorized_and_enabled_sub_item = item.get_last(enabled=True, authorized=True)
     168}}}
     169
     170Number of sub-items:
     171{{{
     172    number_of_subitems = len(item)
     173}}}
     174
     175Position of a sub-item within the sub-items list:
     176{{{
     177    sub_item_position = item.index(sub_item)
     178}}}
     179
     180Check whether this is the first sub-item with certain flags:
     181{{{
     182    is_first_enabled = item.is_first(enabled=True)
     183}}}
     184
     185Check whether this is the last sub-item with certain flags:
     186{{{
     187    is_last_authorized_and_visible = item.is_last(authorized=True, visible=True)
     188}}}
     189
     190Get all preceding siblings of this item within the parent (as list):
     191{{{
     192    preceding_siblings = item.preceding()
     193}}}
     194
     195Get all following siblings of this item within the parent (as list):
     196{{{
     197    following_siblings = item.following()
     198}}}
     199
     200Get the last preceding item with certain flags:
     201{{{
     202    preceding_enabled = item.get_prev(enabled=True)
     203}}}
     204
     205Get the first following item with certain flags:
     206{{{
     207    following_visible_and_enabled = item.get_next(visible=True, enabled=True)
     208}}}
     209
     210Get the item URL:
     211{{{
     212    url = item.url()
     213}}}
     214
     215Get an inherited attribute (i.e. controller, function or application; these attributes should never be accessed directly):
     216{{{
     217    controller = item.get("controller")
     218}}}
     219
     220Check whether this item or any item underneath it contains a certain tag:
     221{{{
     222    tag = "special"
     223    if tag in item:
     224        # This item or at least one underneath it contains this tag
     225}}}
     226
     227==== Manipulation methods ====
     228
     229These methods can be used by controllers to influence the rendering of items:
     230
     231Get all items underneath this item with a certain tag (as list):
     232{{{
     233    tag = "special"
     234    special_items = item.findall(tag)
     235}}}
     236
     237Enable/disable items by tag:
     238{{{
     239    tag = "special"
     240    item.enable(tag) # enables all descendand items with the tag "special"
     241
     242    tag = "nonspecial"
     243    item.disable(tag) # disables all descendand items with the tag "nonspecial"
     244}}}
     245
     246If enable or disable are used without tag, then only the current item gets enabled/disabled
     247
     248Set layout:
     249{{{
     250    tag = "special"
     251    def f(item):
     252        # Layout goes here
     253
     254    # Set this layout to all descendand items with the tag "special"
     255    item.set_layout(f, tag=tag, recursive=True)
     256}}}
    133257==== Rendering Methods ====
    134258=== Invoking the Renderer ===