Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Version 6 and Version 7 of BreadCrumbNaviation


Ignore:
Timestamp:
06/24/07 17:43:27 (11 years ago)
Author:
Chris Arndt
Comment:

migration notice

Legend:

Unmodified
Added
Removed
Modified
  • BreadCrumbNaviation

    v6 v7  
    1 == Bread Crumb Style Naviation using !CherryPy Introspection == 
    2  
    3 This example shows how to implement bread crumb style navigation using introspection.  I like this navigation style and I wanted to implement it using the structure I defined in my controllers.  A hint on the mailing list (thanks Elvelind Grandin) showed me this can be done using cherrypy._cputil.get_object_trail(). 
    4  
    5 I wrote this with SVN revision r800. 
    6  
    71{{{ 
    8 def createNavBarLinks(): 
    9     """Return link information for constructing bread crumb navigation. 
    10  
    11     """ 
    12     cherry_trail = cherrypy._cputil.get_object_trail() 
    13     href = '/' 
    14     crumbs = [(href, 'home')]  
    15     for item in cherry_trail: 
    16         # item[0] is the name you use in the URL to access the controller. 
    17         # item[1] is the actual controller 
    18         if isinstance(item[1], (Controller, BaseDataController)): 
    19             if item[0] != 'root': 
    20                 href = "%s%s/" % (href, item[0]) 
    21                 crumbs.append([href, item[0]]) 
    22     return crumbs 
     2#!rst 
     3.. note:: This page has been migrated to http://docs.turbogears.org/1.0/BreadCrumb. 
    234}}} 
    24  
    25 Now in your kid template, import the function and create your navigation bar. 
    26  
    27 {{{ 
    28         <div id="navbar"> 
    29             <span py:for="href in createNavBarLinks()"> 
    30                 <a class="menu" href="${href[0]}">${href[1]}</a> 
    31             </span> 
    32         </div> 
    33 }}} 
    34  
    35 More info about breadcrumb navigation: http://www.zend.com/zend/spotlight/breadcrumb28.php