Currently, OG views (and thus, URL paths) are:
og: main groups directory
og/my: list of all groups user is sub'd too
og/search: search through the groups.
group/mytracker: recent activities in the sub'd groups.
group/myunread: unread activity in the sub'd groups.
group/tracker: recent activities in all groups.
In short, this doesn't make a lot of sense, and abuses two namespaces. Likewise, even though all those URLs are created via Views, which allows you to change the URLs, the og.module itself hardcodes those paths. The breadcrumb for "Groups" will always be /og (even if it doesn't exist); same with all the URLs in the Group notification block.
I'd like to revise the above to:
groups: main groups directory
groups/my: list of all groups user is sub'd too
groups/my/tracker: recent activities in the sub'd groups.
groups/my/unread: unread activity in the sub'd groups.
groups/search: search through the groups.
groups/tracker: recent activities in all groups.
This is a much stronger layout, and only uses one namespace. I've accomplished most of the above already using Overridden views, but I'd really like to see it in the shipped module. Also, I'd like to see the hardcoded URLs use the values from the Views, so that people can change them as they see fit, and have the blocks/breadcrumbs follow as best as possible.
Is there any support for this change?
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | og_url.patch | 35.94 KB | Duncan Pierce |
| #6 | 162290_started.patch | 1.71 KB | morbus iff |
| #3 | og.5.x-3.1.hardcoded.urls_.txt | 1.36 KB | Duncan Pierce |
Comments
Comment #1
moshe weitzman commentedthis makes sense. one more requirement is that we need to issue a permanent redirect to the new url for existing rss subscriptions.
this is going to break a lot of random links on people's sites. perhaps we should setup aliases for the old urls?
i'd like to see this tackled in 2 steps. first, remove hard coded paths from og and instead query the view as suggested by morbus. then, all the rest, including upgrade path.
Comment #2
damien_vancouver commentedI think this is a great idea, but yes we definitely need a way to alias the old URLs so it won't break pretty much everyone's hardcoded links.
I know I am one of those everyone's on some of the sites I'm responsible for, so I can help with testing the upgrade path once you guys get the first part done.
Comment #3
Duncan Pierce commented+1 on this.
I've audited 5.x-3.1 for hardcoded URLs. Attached is a file describing de-duplicated strings to search for to locate all (I hope) hardcoded refs along with filenames. Probably should have done this tedious task against CVS HEAD but I was an hour in before it occurred to me.
There is a good chance I will have time to tackle some work on removing this duplication over the coming weekend.
I don't feel confident to do all of "first, remove hard coded paths from og and instead query the view as suggested by morbus." but I do feel able to tackle the donkey-work of removing the hardcoded paths. If you want me to have a go at this, I need to know 2 things: (1) which version (3.1, HEAD, etc) you want me to work against and (2) where you want the paths hidden - I favour a new function:
Comment #4
morbus iffDuncan - that's very good work! Always develop against HEAD. And I like the og_url idea.
The actual implementation to get the URLs will be something like:
Comment #5
Duncan Pierce commentedThanks for your support and the pointer to the code Morbus.
Though I haven't thought deeply about it I'm worried about how I will handle the argument substitution in the URL returned by views. So, I will try to get og_url() in place first and report back here with a patch before looking at querying views.
Comment #6
morbus iffSo, moshe, I started this and ran into a bit of a problem. Or, at least, something I didn't fully understand. The default OG view (called "og") has a URL of "og/all" - this is necessary for tabs (alongside "og/my"). So, the literal URL is "og/all", but since it's the default tab, we happily can refer to its URL as "og". Great, dandy. Well, it seems that menu_set_location() (which is what is used in og_nodeapi, 'view') doesn't like the idea of setting locations to the full path of the default tab (ie., "og/all") - my original og_url() function happily returned "og/all" to menu_set_location(), and MSL happily ignored that value (returning the word "Groups" linked to ''). If, on the other hand, I returned simply "og", everything worked dandily. So, that causes the revised og_url() you see in this patch. Likewise, I was unable to get menu_set_location() to do anything for Group home pages, which is why you see me switch off to drupal_set_breadcrumb().
Any comments, suggestions?
Comment #7
morbus iffComment #8
moshe weitzman commentedi'd like for dww to take a look at og_url() since he did he menu tab stuff for Views ... the new drupal_set_breadcrumb() is kind of a bummer. i worked for a while to get rid of those, because people sometimes put 'og' path under something else, that ought to show up in the breadcrumb.
i agree that menu_set_location() is a bit of voodoo.
Comment #9
Duncan Pierce commentedHere's a very simple-minded trawl through the code turning hardcoded URLs into og_url() calls. I'm embarrassed to say I haven't even tested this, but with 80 constants to replace I've lost the will to live.
Search for + // TODO: in the patch as well.
Comment #10
Duncan Pierce commentedHere's a couple of utilities which might be useful. You need GNU M4 with -P.
First, constantify by extracting all og_url('foo') -> define('OG_FOO', 'foo'):
Next, rewrite source file to use references to constants:
Comment #11
thepanz commented+1 for this functionality...
Comment #12
gracearoha commentedHas there been any progress on this?
Comment #13
Duncan Pierce commentedNot that I know of.
I imagine with all the changes that have gone in since I posted my patch it is going to be pretty stale. The original took the better part of 2 days, much of it a code audit that would need to be repeated. I'm unwilling to reroll the patch unless I'm 99% sure it's going to be used.
I hope it does progress though - this could unlock some nice features / changes in future.
Comment #14
GregoryHeller commentedWow, this is an old issue! I just ran into the "hard coded" /og url issue on a site I am building. If a user tries to submit a content type that must be in a group, and the user is not a member of any group they get an error message that reads "You must [join a group] before posting a [content type]" where "[join a group]" is a link to /og.
I've changed the path to my /og view to "/groups" and thus the user gets a 404. The quick solution is to create a redirect or an alias, but the better solution would be for this not to be hard coded.
Comment #15
Chris Einkauf commentedSubscribing.
By the way, in og.module, here is the line that is causing this:
I'd love to be able to just change that url('og') to url('groups'), but I worry that there are other 'og'-related path issues that I am going to encounter in the future. Plus, I always hate hacking modules unless there's absolutely no other way.
Comment #16
Chris Einkauf commentedNot sure whether this should go under HEAD or dev, but since I'm using 6.x-2.0-rc3 I figured applying some sort of version 2 label might be good.
Comment #17
dugh commentedsubscribe
Comment #18
Chris Einkauf commentedJust to update people on what I ended up doing as a temporary hack (until this is resolved in the og module itself): I installed the URL Redirects module and just did a 302 redirect from /og to /groups (for my site, I wanted it to be at the path /groups). This method is just fine for me temporarily, and allowed me to not have to hack into the og module.
Comment #19
landry commentedAnyone looking into this ? It basically forbids one to move away from /og/ urls without using hacks (yeah, a redirect is a hack).
Wondering if it should be moved from 'feature request' to 'bug report' to attract eyes...
Comment #20
crea commentedSubscribing.
Comment #21
locomo commentedsubscribing
Comment #22
manuel garcia commentedIn my opinion, this could be a bug, because it forces you to modify the default views, and therefore have to load them from the db.
You may not want to edit the default views, so that you can then export your own ones into code, to keep things tidy (version control) and fast (loading from code). At the moment, you cannot do this because you need to edit the default ones or everything falls apart. IF you do, then the views are loading from the database.
The idea would be to clone the default ones, modify them, export them to code, and configure OG to use the cloned and modified views. We might want to place a disclaimer about this next to these configurations, reminding users that it would be then their responsibility.
I understand that the maintainers might be a little reluctant for this to happen, because it would mean that in future upgrades, well, the default views might change and the user custom ones might stop working, so this is why I suggest a disclaimer next to the configuration here, and remind them that if something happens, they should repeat the cloning process, and it would fall out of the support request queue, except for documenting what changed in the default view perhaps. This would not be different from having a modified view however, in terms of time, because you would stil need to restore the default and remodify it, so I guess it would not be that much of a deal...
Comment #23
amitaibuLet's keep things as is in D6. In D7 everything should be
og