Please forgive if this is a dumb question - I am a Panels 2 newbie.
So . . . I am trying to do a taxonomy override with a path similar to: /path/[term-name]
(Using term ID in the path does not fit our needs, as well.)
I have created view panes that accept the [term-name] as an argument.
I add these to a panel page I have created that uses [term-name] as an argument itself.
I then add the view panes via content tab - feeding the argument to them using either "Send arguments" or "Additional Arguments" (using "@0").
Both work fine.
The only problem is that we do NOT wish to spaces in our URL (either regular or URL encoded %20).
We would rather use dashes.
This is allowed when creating the View itself (just check "transform spaces to dashes in url"), but they do not work when that same view added as a pane to a panel page.
(Does this make sense?)
Anyways, I have come to the conclusion that:
1.) I am doing something wrong - and there is an easy way to do this (perhaps using contexts?? which I don't quit understand yet)
2.) There is no way to do this in Panels 2 - in which case I would like to request this as a feature request for Panels 3.
3.) Only way to do this is a hack. (I am open to suggestions.)
I also would love to know from more experienced "Pannelers" whether I should wait for Panels 3 to mature before even messing with any of this. (Is there going to be an upgrade path from Panels 2 for D6 to Panels 3? Is Panels 3 alpha 1 just as stable as Panels 2 alpha 3? Where the heck should I start?)
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | ctools-358953-20.patch | 2 KB | cedarm |
| #12 | ctools-358953-12.patch | 2.36 KB | cedarm |
Comments
Comment #1
miiimooosubscribing
Comment #2
miiimoooThe workaround I have found looks like this - my Page has a path "campaign":
I added this to settings.php
This rewrites dashes to underscores and spaces to dashes - assuming that underscores are not being used in term names..
Comment #3
merlinofchaos commentedThe custom URL rewrite is a good one. The taxonomy term argument needs some more intelligence like the Views one has. Right now it's kind of dumb. Patches accepted.
Comment #4
friolator commentedI'm assuming we're seeing the same issue here, in panels 3.0. So is this still an open issue within panels? we have a really odd situation that seems to be related to this:
"places/%region" (taxonomy terms as argument to custom page)
"places/%region/%state" (taxonomy terms as arguments to custom page)
"places/%region/%state/%node-title" (panels system node/view override w/url alias to match the previous two urls)
In the case where the state name has two words ("New York", "New Hampshire", "North Carolina", etc), the argument only works if we leave the space in the term in the URL. If we put in a dash, the page comes up with a 404. In the case of one-word states ("Maine" "Massachusetts," "Wisconsin"), the argument works perfectly.
In the views preview, dashes work fine. I've even tried adding in taxonomy term synonyms (such as "new-hampshire") but that's not doing it. we'd use term ids instead of names, but it's nicer to have the url be human-readable, and hackable, so people can delete the %node-title and see all the places in the state, for instance.
Is there an easy workaround to this? we're closing in on launch and just noticed this problem - it's a bit of an edge case for us, but we'd rather not have spaces in our URLs if we can help it.
Comment #5
merlinofchaos commentedRight now, Panels doesn't have the smarts that Views does in terms of translating arguments for spaces to dashes. There are two workaround:
1) use a string context and pass it directly to Views. This means you can't use the context for Panels specific stuff.
2) Write an argument plugin based on the existing one that will do translations for you. Some of the needed code is already in Views, though it's a little abstracted so may be difficult to utilize.
Comment #6
friolator commentedSince we don't really need the full taxonomy context in this situation, passing it as a string works just fine.
thanks!
Comment #7
merlinofchaos commentedMarking fixed since you seem to have a workaround.
Comment #9
pwilson commentedmiiimooo's workaround worked for me (kudos miiimooo), but I do think it'd be nice to have this built into Panels. I have no Earthly idea how difficult it might be, but if it isn't monumentally difficult I would love to see this in a future release. Keep up the phenomenal work =D
Thanks,
Patrick
Comment #10
dinomight commentedThe post in #2 seems like a good workaround to me, but I'm having trouble understanding how to implement it. I first tried inserting this snippet into my default.settings.php file, but that did nothing for me. I then tried it in settings.php as miiimooo did, but that didn't work either. Whenever I try to include the dashes I need in my url, I get a page not found error.
My url is "2010-totfootball/schools/," so I replaced the word campaign with schools. I also tried replacing it with 2010-totfootball/schools/.
I considered just changing my taxonomy to have the dashes built into the term names, but that won't work since I need to use the normally formatted (with spaces) term name as a title in my panes.
I'm definitely confused at the moment.
Comment #11
theo38 commentedI second the above post - where should this code be placed?
Comment #12
cedarm commentedToday we created our /taxonomy/term/%term override and ran into this same thing. We needed the %term context to pass "term-name" to a panel (a views content pane) rather than "Term Name" or the term id. A patch to ctools provides this via context conversions of %term to term name with spaces transformed to dashes, the reverse of views. This way we can setup the views Argument using the "Transform dashes in URL to spaces in term name arguments" checkbox. It works nicely.
BTW we're only actually using the 'name_dashed' conversion in terms.inc. All of it needs testing...
I think this makes sense to have as part of ctools since it matches views functionality, but does this actually need to be implemented here? Can another module implement a context plugin that will do this? (pathauto?...)
Comment #13
merlinofchaos commentedComment #14
ericclaeren commentedThe ctools patch in #12 worked perfectly for me! Nice work, could this patch be included in a new ctools release?
Comment #15
merlinofchaos commentedCommitted to all branches.
Comment #17
kclarkson commentedI have searched through all the forums and cannot find an easy resolution to this.
Can anybody provide a step by step to allow the panels argument to show urls with hyphens?
Comment #18
cedarm commentedThere's a context token called %term:name_dashed that corresponds to argument from context "Term name, lowercased and spaces converted to dashes" in views. Is that what you need? What are you trying to do with the argument?
Comment #19
kclarkson commented@cedarm,
Thank you for getting back to me so quickly and I apologize ahead of time if I am mixing things up.
I am using panels and views to show a content type of faculty Award and a content type of Award Recipients. So both content types are sharing the same taxonomy terms so I would like to show them both on one page.
I have the panels arguments working for terms that have one word, but when they have spaces it says argument is not available. I tried entering hypens but it only works when adding %20 in for the spaces of the url.
So I have done the following:
1. Created a default view with some fields and an Argument of Taxonomy Term
2. Added a "content pane", display,
2a Added basic validation
2b checked the transfer spaces to dashes
2c. In the Pane Settings under the Argument Input I selected "from Panel Argument" and first.
3. Created a Panel Page
3a. Added argument, used taxonomy term ID, selected "term name" and limited to my vocabulary of "awards and funding"
3b Created a custom path of. %term I also tried %1
PS. I understand you gave me a context token that would use dashes. I added your context token to the url and it did not work. If you could explain a little bit more about the context token I should be able to figure it out.
Comment #20
cedarm commentedkclarkson needs this same feature in the term arguments plugin, for his step 3a. Here's a stab at it. This may be used with or without the corresponding views transform.
Comment #21
kclarkson commentedbump
Comment #22
calefilm commentedI followed all of Kclarkson's steps.. Did this patch help you?
If I apply this patch will this resolve my issue? I'm currently using 6.x-1.8--I didn't know if it was worth using Dev.
In my case, a user is coming from another page, having clicked a link called "Western Digital" to view the Western Digital Review page. Each Brand's review page has a corresponding taxonomy term, i.e. "Western Digital". reviews/%brand
My example: reviews/%brand where "Western Digital" is the brand. I'm trying to tell my panel page to transform spaces to dashes but have tried kclarkson's steps to no avail.
I'm confused by this... I don't see this option.. and if I add it to my URL as Kclarkson did it doesn't work as my pane argument tab stops working.
Very confused how to set this all up.
Comment #23
cedarm commentedYou don't need to use dev. Just apply the patch from #20.
There are two things you must get right.
- panels must be able to convert the page path into a context (using a panels argument)
- you must pass the correct type of argument from panels to views
These are two different arguments. You do not need to use the same type for both. For example
reviews/%brand (term dashed) -> term context -> term id -> viewsor
reviews/%brand (term dashed) -> term context -> term name (dashed) -> viewsare equally valid, but views must be expecting whatever argument you send it. Likewise, %brand could be a term id itself:
reviews/%brand (term id) -> term context -> term id -> viewsor
reviews/%brand (term id) -> term context -> term name (dashed) -> viewsDecide for yourself which makes sense for your site, then configure BOTH appropriately.
Comment #24
kclarkson commentedCan we get this patch tested and committed?
I have tough time adding patches and I update my modules frequently.
Comment #25
calefilm commentedThanks Cedarm,
I really appreciate your assistance. I did set the panel argument correctly and it works although I don't know if my further issue is related.
So now, if a user types in mysite.com/reviews/western-digital the panel page works.
But I have a separate page of all listed brands being reviewed:
Sony
Western-Digital
Panasonic
Within this view, I've added a field, node title: Brand Label. Within this field, I have an "Output this field as a link": reviews/[field_brand_label_value]
(keep in mind, all "brand labels" are node titles which were referenced from the Taxonomy Terms list upon creating the node)
When I go to this view, I see:
Sony
Western Digital
Panasonic.
I click the Western Digital link, and the URL reads: mysite.com/reviews/western%20digital
UPDATE: This seems to be a bigger issue than I thought. I found a couple open issues regarding this problem: http://drupal.org/node/514078#comment-2031486 I did try Path Redirect module. This doesn't quite fix my problem as I have hundreds of links to fix--it would not be feasible.
Comment #26
cedarm commented@calefilm - you got it; separate issue. Personally I'd probably theme the views field and do the replace in a theme or preprocess function.
Comment #27
kclarkson commentedDoes calefilm's usage count as the patch being tested?
Comment #28
calefilm commentedI've themed the views before but to "do the replace in a theme or preprocess function" is beyond my scope entirely." Appreciate your responses, cedarm. Luck
Comment #29
webavant commentedAfter reading your comment (#20), it's not totally clear what you have changed with this patch, but I do notice that you added the "term name (dashed)" argument handler, which was exactly what I needed. I tested the patch in #20 and have not noticed any errors. It did exactly what I needed and made my day. Thanks.
Comment #30
cedarm commented@webavant that's exactly what the patch in #20 adds, another option in the argument handler.
Comment #31
summit commentedHi, Is this patch committed already?
Thanks for your reply in advance.
greetings, Martijn
Comment #32
mstrelan commentedIs any of this available in Drupal 7 version? It doesn't seem like it.
Comment #33
robertom commentedsubscribe for future reading (interested on Drupal 7 version)
Comment #34
mstrelan commentedIn addition to my comment in #32 here is what I am trying to achieve
I want to set up eat-and-drink/search/%dining_type to point 301 redirect to eat-and-drink/search?dining_type=%dining_type:tid but ideally the first instance of %dining_type should be %dining_type:name_dashed however that doesn't seem to work.
Comment #35
mstrelan commentedSometimes coming back to something the next day reveals that there was a much better approach. For #34 instead I created a variant for taxonomy/term/%taxonomy_term which performed my 301 redirect, and I setup pathauto to alias my dining type vocabulary terms to eat-and-drink/search/[term:name] which handles the hyphens for me.
Still, I think what I was initially attempting should work.
Comment #36
cedarm commentedThat patch in #12 was committed; the patch in #20 has not yet and is what you need. Do you see %dining_type:name_dashed in the page context?
Comment #37
mstrelan commentedNo
Comment #38
cedarm commentedSo that's why it didn't work. Have you applied the patch in #20? I tried it for your use case and it works for me.
Edit: I take that back. #20 is for handling term name dashed arguments.
Comment #39
rlmumfordIs there a Drupal 7 version of this patch? Or are they the same?
Comment #40
Josh Benner commented#20 works for me.
Comment #41
pelicani commented#20 works for me.
thanks!
Comment #42
Jason Dean commentedAlso interested to know whether #20 works in D7?
Comment #45
japerryThis was fixed by Merlinofchaos