Breadcrumbs plugin

View: New views
14 Messages — Rating Filter:   Alert me  

Breadcrumbs plugin

by Darryl Pentz () :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've designed a breadcrumbs 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
                        }
                    }                    
                }
.
.
.
}

Breadcrumbs plugin

by Darryl Pentz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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



Re: Breadcrumbs plugin - need advice

by Darryl Pentz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

Some time back I posted the comment below to which nobody responded. I'm not complaining cos i understand the nature of a forum, but I'm just asking again if anybody has any good ideas regarding my main problem indicated below - because I'm back to working on this plugin and haven't yet thought of a good solution. Particularly those of you who have done some plugin development already.

Muchos gracias.

- Darryl Pentz

Darryl Pentz wrote:
I've designed a breadcrumbs 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
                        }
                    }                    
                }
.
.
.
}

Re: Breadcrumbs plugin - need advice

by Miguel Ping :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm kinda new to grails, and I would really like a breadcrumbs plugin. I have a perhaps dumb question? Isn't it easier to *somehow* plugin into the UrlMappings and decode the current user position based on the incoming request? It seems to me that you are replicating the url mapping structure by hand. Don't know if it's possible though, its just a thought...

Cheers,
Miguel

On Thu, May 15, 2008 at 10:49 AM, Darryl Pentz <djpentz@...> wrote:

Hi all,

Some time back I posted the comment below to which nobody responded. I'm not
complaining cos i understand the nature of a forum, but I'm just asking
again if anybody has any good ideas regarding my main problem indicated
below - because I'm back to working on this plugin and haven't yet thought
of a good solution. Particularly those of you who have done some plugin
development already.

Muchos gracias.

- Darryl Pentz


Darryl Pentz wrote:
>
> I've designed a breadcrumbs 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/Breadcrumbs-plugin-tp17017903p17249643.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




Parent Message unknown Re: Breadcrumbs plugin - need advice

by Darryl Pentz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi Miguel,

Yes indeed, there is a similarity to the UrlMappings of the Grails application, but the problem of course is that the UrlMappings might be very simple with 2 closures for the root and for controller/action/id, whereas a breadcrumbs tree is usually a lot deeper, broader.

I do however in fact use a class derived from the Grails UrlMappings class in my breadcrumbs plugin.

- Darryl

----- Original Message ----
From: Miguel Ping <miguel.ping@...>
To: user@...
Sent: Thursday, May 15, 2008 2:18:10 PM
Subject: Re: [grails-user] Breadcrumbs plugin - need advice

Hi,

I'm kinda new to grails, and I would really like a breadcrumbs plugin. I have a perhaps dumb question? Isn't it easier to *somehow* plugin into the UrlMappings and decode the current user position based on the incoming request? It seems to me that you are replicating the url mapping structure by hand. Don't know if it's possible though, its just a thought...

Cheers,
Miguel

On Thu, May 15, 2008 at 10:49 AM, Darryl Pentz <djpentz@...> wrote:

Hi all,

Some time back I posted the comment below to which nobody responded. I'm not
complaining cos i understand the nature of a forum, but I'm just asking
again if anybody has any good ideas regarding my main problem indicated
below - because I'm back to working on this plugin and haven't yet thought
of a good solution. Particularly those of you who have done some plugin
development already.

Muchos gracias.

- Darryl Pentz


Darryl Pentz wrote:
>
> I've designed a breadcrumbs 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/Breadcrumbs-plugin-tp17017903p17249643.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





RE: Breadcrumbs plugin - need advice

by Callaway, Pamela :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

So… does that mean there is a breadcrumbs plugin?  Do you have a link for those of us who would like to check it out?

 

Thanks,

 

Pam

 

From: Darryl Pentz [mailto:djpentz@...]
Sent: Thursday, May 15, 2008 8:57 AM
To: user@...
Subject: Re: [grails-user] Breadcrumbs plugin - need advice

 

Hi Miguel,

Yes indeed, there is a similarity to the UrlMappings of the Grails application, but the problem of course is that the UrlMappings might be very simple with 2 closures for the root and for controller/action/id, whereas a breadcrumbs tree is usually a lot deeper, broader.

I do however in fact use a class derived from the Grails UrlMappings class in my breadcrumbs plugin.

- Darryl

----- Original Message ----
From: Miguel Ping <miguel.ping@...>
To: user@...
Sent: Thursday, May 15, 2008 2:18:10 PM
Subject: Re: [grails-user] Breadcrumbs plugin - need advice

Hi,

I'm kinda new to grails, and I would really like a breadcrumbs plugin. I have a perhaps dumb question? Isn't it easier to *somehow* plugin into the UrlMappings and decode the current user position based on the incoming request? It seems to me that you are replicating the url mapping structure by hand. Don't know if it's possible though, its just a thought...

Cheers,
Miguel

On Thu, May 15, 2008 at 10:49 AM, Darryl Pentz <djpentz@...> wrote:


Hi all,

Some time back I posted the comment below to which nobody responded. I'm not
complaining cos i understand the nature of a forum, but I'm just asking
again if anybody has any good ideas regarding my main problem indicated
below - because I'm back to working on this plugin and haven't yet thought
of a good solution. Particularly those of you who have done some plugin
development already.

Muchos gracias.

- Darryl Pentz


Darryl Pentz wrote:
>
> I've designed a breadcrumbs 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/Breadcrumbs-plugin-tp17017903p17249643.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

 

 


RE: Breadcrumbs plugin - need advice

by Darryl Pentz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Pam,

No not yet unfortunately. I just wanted to make that one configuration change before putting it up anywhere. As soon as I can figure out a more Grails-like approach. :)

- Darryl

Callaway, Pamela wrote:
So... does that mean there is a breadcrumbs plugin?  Do you have a link for those of us who would like to check it out?

Thanks,

Pam

From: Darryl Pentz [mailto:djpentz@yahoo.com]
Sent: Thursday, May 15, 2008 8:57 AM
To: user@grails.codehaus.org
Subject: Re: [grails-user] Breadcrumbs plugin - need advice

Hi Miguel,

Yes indeed, there is a similarity to the UrlMappings of the Grails application, but the problem of course is that the UrlMappings might be very simple with 2 closures for the root and for controller/action/id, whereas a breadcrumbs tree is usually a lot deeper, broader.

I do however in fact use a class derived from the Grails UrlMappings class in my breadcrumbs plugin.

- Darryl
----- Original Message ----
From: Miguel Ping <miguel.ping@gmail.com>
To: user@grails.codehaus.org
Sent: Thursday, May 15, 2008 2:18:10 PM
Subject: Re: [grails-user] Breadcrumbs plugin - need advice

Hi,

I'm kinda new to grails, and I would really like a breadcrumbs plugin. I have a perhaps dumb question? Isn't it easier to *somehow* plugin into the UrlMappings and decode the current user position based on the incoming request? It seems to me that you are replicating the url mapping structure by hand. Don't know if it's possible though, its just a thought...

Cheers,
Miguel
On Thu, May 15, 2008 at 10:49 AM, Darryl Pentz <djpentz@yahoo.com<mailto:djpentz@yahoo.com>> wrote:

Hi all,

Some time back I posted the comment below to which nobody responded. I'm not
complaining cos i understand the nature of a forum, but I'm just asking
again if anybody has any good ideas regarding my main problem indicated
below - because I'm back to working on this plugin and haven't yet thought
of a good solution. Particularly those of you who have done some plugin
development already.

Muchos gracias.

- Darryl Pentz


Darryl Pentz wrote:
>
> I've designed a breadcrumbs 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<http://profile.id>}"
>                         return profile.name<http://profile.name>
>                     }
>
>                     Profile profile = context.profile
>                     context.url = "/profile/summary/${profile.id<http://profile.id>}"
>                     return profile.name<http://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<http://profile.id>}"
>                             return "Devices"
>                         }
>
>                         profile = context.profile
>                         context.url = "/profile/listDevices/${profile.id<http://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<http://device.id>}"
>                             return device.hostname
>                         }
>                     }
>                 }
> .
> .
> .
> }
>

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


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

   http://xircles.codehaus.org/manage_email



Re: Breadcrumbs plugin - need advice

by Peter Ledbrook-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2008/5/15 Darryl Pentz <djpentz@...>:
>
> Hi all,
>
> Some time back I posted the comment below to which nobody responded. I'm not
> complaining cos i understand the nature of a forum, but I'm just asking
> again if anybody has any good ideas regarding my main problem indicated
> below - because I'm back to working on this plugin and haven't yet thought
> of a good solution. Particularly those of you who have done some plugin
> development already.

A couple of other options:

  * Create your own artefact (like filters) - a user could then easily
break the configuration up across multiple files/classes
  * Put the config in a different *Config.groovy file that can be
included from the main Config.groovy

Actually, Grails may load all files that match the pattern
"grails-app/conf/*Config.groovy", but I'm not sure. I would have to
check.

HTH,

Peter

--
Software Engineer
G2One, Inc.
http://www.g2one.com/

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

    http://xircles.codehaus.org/manage_email



Parent Message unknown Re: Breadcrumbs plugin - need advice

by Darryl Pentz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Peter, some very good ideas for me to look into.

- DP

----- Original Message ----
From: Peter Ledbrook <peter@...>
To: user@...
Sent: Thursday, May 15, 2008 5:56:51 PM
Subject: Re: [grails-user] Breadcrumbs plugin - need advice

2008/5/15 Darryl Pentz <djpentz@...>:
>
> Hi all,
>
> Some time back I posted the comment below to which nobody responded. I'm not
> complaining cos i understand the nature of a forum, but I'm just asking
> again if anybody has any good ideas regarding my main problem indicated
> below - because I'm back to working on this plugin and haven't yet thought
> of a good solution. Particularly those of you who have done some plugin
> development already.

A couple of other options:

  * Create your own artefact (like filters) - a user could then easily
break the configuration up across multiple files/classes
  * Put the config in a different *Config.groovy file that can be
included from the main Config.groovy

Actually, Grails may load all files that match the pattern
"grails-app/conf/*Config.groovy", but I'm not sure. I would have to
check.

HTH,

Peter

--
Software Engineer
G2One, Inc.
http://www.g2one.com/

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

    http://xircles.codehaus.org/manage_email


     

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

    http://xircles.codehaus.org/manage_email



Re: Breadcrumbs plugin - need advice

by Josh Joy-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I will be needing breadcrumbs for my app...I would be interested in the code as well...

On Thu, May 15, 2008 at 10:56 AM, Peter Ledbrook <peter@...> wrote:
2008/5/15 Darryl Pentz <djpentz@...>:
>
> Hi all,
>
> Some time back I posted the comment below to which nobody responded. I'm not
> complaining cos i understand the nature of a forum, but I'm just asking
> again if anybody has any good ideas regarding my main problem indicated
> below - because I'm back to working on this plugin and haven't yet thought
> of a good solution. Particularly those of you who have done some plugin
> development already.

A couple of other options:

 * Create your own artefact (like filters) - a user could then easily
break the configuration up across multiple files/classes
 * Put the config in a different *Config.groovy file that can be
included from the main Config.groovy

Actually, Grails may load all files that match the pattern
"grails-app/conf/*Config.groovy", but I'm not sure. I would have to
check.

HTH,

Peter

--
Software Engineer
G2One, Inc.
http://www.g2one.com/

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

   http://xircles.codehaus.org/manage_email