Closed (fixed)
Project:
MySite
Version:
5.x-1.10
Component:
- Type plugin
Priority:
Minor
Category:
Feature request
Assigned:
Reporter:
Created:
1 Nov 2006 at 19:14 UTC
Updated:
5 Mar 2007 at 02:07 UTC
Jump to comment: Most recent file
It would be nice to have pathauto support
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | path.txt | 3.05 KB | agentrickard |
Comments
Comment #1
agentrickardI took a look at this and implementation is not trivial. It would also force someone (likely me) to keep track of pathauto development.
Since pathauto is not core, I'm not overly eager to support it right now.
You can also configure the module so that users who go to http://example.com/mysite are automatically redirected to the proper page http://example.com/mysite/UID/view, so adding path aliasing doesn't gain you a whole lot on the marketing or ease-of-use levels.
Let's get the real use cases and bugfixes out of the way first.
Comment #2
agentrickardI was thinking more about this, and respecting path rewrites works, but keeping up with pathauto changes seems a burden.
It would be easier to create a setting for MySite that allowed admins to choose to alias mysite paths.
The option would only be active if the path.module were active.
The settings would be:
The default path would be mysite/USERNAME == mysite/UID/view.
Would this setting need to be configurable beyond that?
If this setting were in effect, the module would create a path alias whenever someone created a new MySite (or updated an existing one).
Comment #3
agentrickardThis is technically supported by the 4.7.x.3.0 release.
One could write a path.inc file to handle the creation of aliases. Doing so is easier to support than pathauto integration.
Comment #4
xamox commentedYeah, all the above sounds good. Keep up the good work!
Comment #5
csc4 commentedI successfully did an inc for biblio but I just can't my head around how to do a path.inc for this functionality and I don't understand your remark about being technically supported by 4.7.x.3.0 as I can't seem to find any such setting?
Could you give me a pointer? or a path.inc?!
Comment #6
agentrickardIt would probably be done entirely in the admin/settings/mysite tab. Most of the public hooks for MySite wouldn't be used.
We'd set up the following functions:
* mysite_type_path()
* mysite_type_path_settings()
* mysite_type_path_settings_form()
* mysite_type_path_update()
In the README, see:
What we'd do is use the settings function to create the path rules, much like pathauto does.
Then when mysite_type_path_update() is invoked, we'd check to see if a path alias exists for the user. if not, we'd create one.
This sounds fairly simple. I'll take a quick pass at it. The only issue may be that other mysite_type_{name} functions are required for the module to function correctly.
Comment #7
agentrickardBTW, it took me from the time of last post until now to write the plugin.
It needs some work, but try the attached file. Put it in your mysite/plugins/types director and rename it to path.inc (Drupal.org won't let me attach a .inc file for security reasons).
path.inc, compatible and tested against MySite 5.x.1.9. You may have to make a few modifications to make it work in 4.7.x.
Some notes:
* I created two path settings: /mysite/name and /mysite/name/view, just to test. See the switch() case in mysite_type_path_update() to see how these are implemented.
* You must enable the PATH type under 'Display Settings'
* I have not tested what happens to user names with spaces or special characters. These might be a problem, though I think they are handled by http://api.drupal.org/api/5/function/path_set_alias.
* The aias is only created if you update a MySite page (add content, change settings, remoce content).
Next steps:
* Test odd user names (spaces, $#!@ characters).
* Define path mapping defaults. I don't really see a need for pathauto-style configuration. Is any data other than username really important here?
* Add an administrative setting to create aliases for all existing MySite users -- if this is needed. It might be best not to overload the {url_alias} table with users who never user their MySite page. So this feature is probably not needed, IMO.
Let me know how it works out.
Comment #8
agentrickardChanging title
Comment #9
askike commentedI think this is a useful feature and am testing out the .inc file. So far, it's working for me in re-directing from mysite/user to mysite/uid. It would be helpful, though, if the location bar still showed the mysite/user address instead of the mysite/uid so users could copy the link and send it to a friend, etc. Or alternatively, maybe the link could be presented somehow to the user so it is easy to remember or forward the link. Hopefully I'm explaining this clearly enough...
Thanks for your work on this!
Comment #10
agentrickardActually I don't understand.
Drupal's behavior with path aliases is as follows:
* A given system path (/mysite/1/view) is mapped to a path alias (mysite/ken)
* All menu items and l() functions that refer to a given system path are presented to the user with the alias instead.
So when I test the path.inc, I get this when clicking on the default menu link (My drupal):
http://127.0.0.1/drupal-5.1/?q=mysite/ken
Which is equivalent to http://127.0.0.1/drupal-5.1/?q=mysite/1/view
The alias shows up in the browser URL and can be sent to others.
Because of how I have the menus implemented, the 'View MySite' tab still shows /mysite/1, so that may be what you are referring to.
Comment #11
askike commentedYou're right. I overlooked the "path" tab and so missed enabling the "Automatically create path aliases" setting, but everything works perfectly now. Thanks!
Comment #12
agentrickardRight, I get it.
Because of the plugin architecture of MySite, I could add the Path tab without changing the core module. Type include files can have their own settings, so that's why we can test path.inc without have to alter the core module.
After a little more acceptance testing and feedback, I'll roll path.inc into the main release.
Setting to 'patch (code needs review)'.
To test this patch, download http://drupal.org/files/issues/path.txt, rename the file to
path.incand place it in your mysite/plugins/types/ directory.You will then see a Path tab under the MySite settings page.
Activating the Path plugin will auto-alias all MySites the next time a user updates the page (by adding content, removing content, or changing any settings).
Features for path.inc are still in flux, so commenting is open.
Comment #13
agentrickardComments before I commit the code that I have?
Comment #14
askike commentedWorks fine on my test site.
Comment #15
agentrickardI took the settings out, since there is no use-case for a path other than mysite/username.
Available in 5.x.1.10