I'm using a view to create a list of images that should have only fragments in the href attribute like this:
<a href="#products"><img src="xxx"></a>
But in the "Link path" field of "Output this field as a link" there's only two options as described by the help text:
The Drupal path or absolute URL for this link.
I want to add fragments *only*, but that's not possible in the "Link path" field, right?
To add a fragment there would have to be a separate field like alt text and target, right?
I've read #399534: Add fragment and query to render_as_link but that wasn't not for "Output this field as a link" if I understood it correctly.
Comments
Comment #1
merlinofchaos commentedUnfortunately at this time, fragments can not be placed in Views' linking mechanism.
Comment #2
AdrianB commentedOk, thanks for the answer! It was what I expected from what I've tried so far, I just wanted to be sure.
Comment #3
merlinofchaos commentedAtually, I'm wrong. You can use fragments. What you currently cannot do is have fragment only, since trying to put just, for example, "#foo" as the link will try to link to /#foo. Perhaps we can assume that a link that has a fragment and no path should go to the current page.
Comment #4
AdrianB commentedYes exactly, it was the *only* part I was asking about.
My workaround was to specify the complete path like
about#[replacement_pattern]to achievehttp://example.com/about#products. That is working like it should. The drawback is that the view is not generic, I have to create additional displays for other paths (or perhaps use some other clever replacement pattern magic if possible).That would solve my issue, I don't know if it has any drawbacks though. (What if you actually want
/#foo? I guess<front>#foowould solve that.)Comment #5
myxelf commentedSubscribing...
Comment #6
dawehnerHere is a patch for it
Comment #7
myxelf commentedAgghhhh! I was working on a patch to address this issue (well at least an attempt, the very first one)...
Anyway, the patch works for me...
Thanks a lot!
Comment #8
dawehnerIf you susbcribe, but you mean you want to do something you could also assign the issue.
Comment #9
myxelf commentedI supposed that assigning issues to myself should be authorized by some project-more-important-person. I never thought you were going to move that fast! Thanks for the advice.
Comment #10
merlinofchaos commentedActually it doesn't. We do have the problem of people assigning to self and not following through, but it's perfectly legit (and a good idea) to say "I'm working on this!" and if too much time goes by we'll ignore it. But in the short term it can prevent what just happened.
That said, I do not want to criticize you at all, because, hey, people writing patches is a good thing. Please continue! =)
Also, thanks for testing it. That helps.
Comment #11
myxelf commentedI would like to know if there is anything else that can be done to get this commited.
Thanks
Comment #12
merlinofchaos commentedCommitted to all branches.
Comment #13
AdrianB commentedThanks dereine and merlinofchaos!