Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting the last link as the current url #28

Closed
brendon opened this issue Dec 19, 2013 · 9 comments
Closed

Setting the last link as the current url #28

brendon opened this issue Dec 19, 2013 · 9 comments
Assignees
Labels

Comments

@brendon
Copy link
Contributor

brendon commented Dec 19, 2013

Hi Lasse :)

I'm having trouble with this code:
https://github.com/lassebunk/gretel/blob/master/lib/gretel/link_renderer.rb#L80

where it sets the link of the last crumb to be that of the current url. Is there a way to turn this off? I don't display a crumb for the current page so this overwrites what I intend to be the link for the parent crumb.

@brendon
Copy link
Contributor Author

brendon commented Dec 19, 2013

Just following this up. Perhaps I'm using the gem wrong but this is what I'm doing:

crumb :site_settings do
    link "Site Settings", edit_admin_site_settings_path
end

crumb :theme do |theme|
  parent :site_settings
end

crumb :theme_assets do |theme|
  parent :site_settings
end

crumb :users_and_groups do
  link "Users & Groups", admin_users_path
end

crumb :user do
  parent :users_and_groups
end

crumb :group do
  parent :users_and_groups
end

crumb :component_instance do |component_instance|
  parent :parent_component_instance, component_instance.parent if component_instance.parent
end

crumb :parent_component_instance do |parent_component_instance|
    parent_component_instance.self_and_ancestors.each do |component_instance|
        link component_instance.name, [:admin, component_instance]
    end
end

Then this is my renderer:

- breadcrumbs(:display_single_fragment => true, :link_current => true) do |links|
    - if links.any?
        %ul.breadcrumb
            - links.each do |link|
                %li
                    = link_to link.text, link.url
                    %span.divider >

I think I might have mentioned this before but I just use the page heading as the 'current breadcrumb' so it looks like

Home > Classrooms > Room 1
Maths (that's the heading)

I find it more flexible. It also more easily allows for multiple actions per object (i.e. see :user and :group - the new and edit actions render nicely because the page title is say 'Edit User' and the crumbs just point to the parent (:users_and_groups). If there's another way to code up what I'm trying to achieve I'd be happy to give it a try :) I thought I could probably code around this by putting blank links for each crumb and then not rendering the last link in the array in my custom renderer but this seems messy. I'll see if I can make a patch that allows the feature to be turned off.

@brendon
Copy link
Contributor Author

brendon commented Dec 19, 2013

This seems to do the trick though: #29

It leaves your default behaviour in place but allows one to disable it. Added a test for it too :)

@lassebunk
Copy link
Owner

Hmm, I see that.
I think I'll disable it altogether. I think the only place this is actually used is in the gretel-trails gem, so I think it it should actually go there.
Thanks for pointing to this.

@brendon
Copy link
Contributor Author

brendon commented Dec 20, 2013

Thanks Lasse :) I'm continually amazed at how much simpler gretel is to my
previous attempts at breadcrumbs! I'm re-writing my product from scratch
and it's saving so much time :)

I've still yet to test your test helpers but will report back when I do.

Merry Christmas!

Brendon

On Fri, Dec 20, 2013 at 11:06 AM, Lasse Bunk notifications@github.comwrote:

Hmm, I see that.
I think I'll disable it alltogether. I think the only place this is
actually used is in the gretel-trails http://lassebunk/gretel-trailsgem, so I think it it should actually go there.
Thanks for pointing to this.


Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-30971159
.

@lassebunk
Copy link
Owner

Okay, glad to hear you like it.

Maybe wait a bit on the test helpers as I'm not sure about the
implementation. Think it's too messy and unlogical so I think I'll revert
it and do something else.

Thanks, and merry Christmas :-)

fredag den 20. december 2013 skrev Brendon Muir :

Thanks Lasse :) I'm continually amazed at how much simpler gretel is to my
previous attempts at breadcrumbs! I'm re-writing my product from scratch
and it's saving so much time :)

I've still yet to test your test helpers but will report back when I do.

Merry Christmas!

Brendon

On Fri, Dec 20, 2013 at 11:06 AM, Lasse Bunk <notifications@github.com<javascript:_e({}, 'cvml', 'notifications@github.com');>>wrote:

Hmm, I see that.
I think I'll disable it alltogether. I think the only place this is
actually used is in the gretel-trails http://lassebunk/gretel-trailsgem,
so I think it it should actually go there.
Thanks for pointing to this.


Reply to this email directly or view it on GitHub<
https://github.com/lassebunk/gretel/issues/28#issuecomment-30971159>
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-30981848
.

@brendon
Copy link
Contributor Author

brendon commented Jan 19, 2014

Thanks Lasse :) Hope you had a good holiday!

On Fri, Dec 20, 2013 at 2:11 PM, Lasse Bunk notifications@github.comwrote:

Okay, glad to hear you like it.

Maybe wait a bit on the test helpers as I'm not sure about the
implementation. Think it's too messy and unlogical so I think I'll revert
it and do something else.

Thanks, and merry Christmas :-)

fredag den 20. december 2013 skrev Brendon Muir :

Thanks Lasse :) I'm continually amazed at how much simpler gretel is to
my
previous attempts at breadcrumbs! I'm re-writing my product from scratch
and it's saving so much time :)

I've still yet to test your test helpers but will report back when I do.

Merry Christmas!

Brendon

On Fri, Dec 20, 2013 at 11:06 AM, Lasse Bunk <notifications@github.com<javascript:_e({},
'cvml', 'notifications@github.com');>>wrote:

Hmm, I see that.
I think I'll disable it alltogether. I think the only place this is
actually used is in the gretel-trails http://lassebunk/gretel-trailsgem,

so I think it it should actually go there.

Thanks for pointing to this.


Reply to this email directly or view it on GitHub<
https://github.com/lassebunk/gretel/issues/28#issuecomment-30971159>
.


Reply to this email directly or view it on GitHub<
https://github.com/lassebunk/gretel/issues/28#issuecomment-30981848>
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-30982033
.

@lassebunk
Copy link
Owner

Thanks – it was good :-)

@ehlyzov
Copy link

ehlyzov commented Jan 28, 2014

Hi, Lasse!
Thanks for the neat gem :-) Is there any issues with related PR? I have similar layout with @brendon and prefer using header to stress current crumb too. It would be nice to have proposed option.

@brendon
Copy link
Contributor Author

brendon commented Jan 28, 2014

Hi Eugene, in the meantime you can use my fork and branch if you like.
Lasse is going to remove the feature anyway but this gets around it in the
meantime:

https://github.com/brendon/gretel/tree/Optionall-re-link-last-crumb-to-current-url

On Tue, Jan 28, 2014 at 11:29 PM, Eugene Hlyzov notifications@github.comwrote:

Hi, Lasse!
Thanks for the neat gem :-) Is there any issues with related PR? I have
similar layout with @brendon https://github.com/brendon and prefer
using header to stress current crumb too. It would be nice to have proposed
option.

Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-33466692
.

@WilHall WilHall self-assigned this Jul 4, 2016
@WilHall WilHall added the feature label Jul 4, 2016
WilHall added a commit that referenced this issue Jul 10, 2016
WilHall added a commit that referenced this issue Jul 10, 2016
tkawa pushed a commit to tkawa/gretel that referenced this issue Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants