« Return to Thread: Breadcrumbs plugin

Breadcrumbs plugin

by Darryl Pentz :: Rate this Message:

Reply to Author | View in Thread


D'ugh. Obviously that should have been titled "Breadcrumbs plugin" :-(


Darryl Pentz wrote:

>
> I've designed a bookmarks plugin which i'd be happy to throw into the mix,
> though it's got one key flaw which I'd like to address first, and perhaps
> I could get some suggestions of how to do this.
>
> The approach I took for Breadcrumbs is not "this is the path you've taken"
> but rather "this is where you are in our site structure". So what I did
> was to 'define' this structure using a nesting of closures and or strings
> and I build an object tree from this nesting - the breadcrumbs
> configuration. The thing is, I wasn't sure where to put it so I slapped it
> into Config.groovy, but I've found this to be cumbersome and as my
> breadcrumbs tree grows, it really clutters up Config.groovy. So the main
> question and the purpose of this post is, where would a good place be to
> define this tree, if not in Config.groovy, given it's syntax?
>
> Some more background: With this tree in place, I use a taglib to try and
> match the incoming URL against the tree, and it creates a breadcrumbs path
> from that. Now the biggest challenge was how to deal with the dynamic
> nature of the content... for instance if a user were to click on a search
> result that took them to a node 3 levels deep into the tree, some of its
> parent nodes might need to know a bit more about themselves if their
> position contains dynamic content. So I have a 'context' map object that
> is passed into each closure specified in the tree as the taglib climbs up
> the path from the child to the root parent. And it's up to you the
> developer to place necessary objects into that context so that parent
> nodes can figure out whatever they need to about themselves. If a node has
> dynamic content in its url, it should also specify a context.url param
> which the breadcrumb tag will use as the url for that particular node.
>
> At the end of this post is a sample of the breadcrumbs tree. You'll see
> you can specify a label as either a static String, or you can dynamically
> calculate it. If a URL has parameters (as per UrlMappings syntax), those
> are placed into the context as 'args'.
>
> So, assuming what I said makes sense, anybody got a good suggestion of a
> better place to put this tree configuration? Feedback, comments and
> suggestions welcome.
>
> Thanks,
> Darryl Pentz
>
> breadcrumbs = {
>     showHomeLink = false
>     layout {
>         "/profile/list" {
>             pseudonyms = "/,/profile"
>             label = "Profiles"
>             "/profile/summary/$id" {
>                 label = {context ->
>                     if (context.args) {
>                         Profile profile =
> Profile.get(Long.valueOf(context.args[0]))
>                         context.url = "/profile/summary/${profile.id}"
>                         return profile.name
>                     }
>
>                     Profile profile = context.profile
>                     context.url = "/profile/summary/${profile.id}"
>                     return profile.name
>                 }
>                 "/profile/listDevices/$id" {
>                     label = { context ->
>                         Profile profile;
>                         if (context.args) {
>                             profile =
> Profile.get(Long.valueOf(context.args[0]))
>                             context.profile = profile
>                             context.url =
> "/profile/listDevices/${profile.id}"
>                             return "Devices"
>                         }
>
>                         profile = context.profile
>                         context.url = "/profile/listDevices/${profile.id}"
>                         return "Devices"
>                     }
>                     "/device/summary/$id" {
>                         label = {context ->
>                             Device device =
> Device.get(Long.valueOf(context.args[0]))
>                             context.profile = device.profile
>                             context.url = "/device/summary/${device.id}"
>                             return device.hostname
>                         }
>                     }                    
>                 }
> .
> .
> .
> }
>

--
View this message in context: http://www.nabble.com/Bookmarks-plugin-tp17017903p17017949.html
Sent from the grails - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Breadcrumbs plugin

LightInTheBox - Buy quality products at wholesale price