There is a site powered by a proprietary CMS that needs to be moved to Drupal.
This site is bilingual, and has a directory of info resources, with article URL's looking like this:
example.com/en/resources/books/123.
This site has a couple of subsections focusing on more specific topics, with "subhome" pages like this:
example.com/en/topic1 and example.com/en/topic2, that have a modified theming.
Each article can be accessed from the "subhome" pages, too. In this case, its URL looks like this:
example.com/en/topic1/resources/books/123.
So, each article can be accessed via multiple URLs (without any topic prefix, with topic1 prefix, with topic2 prefix, etc.), which affects page theming and visibility of navigation blocks.
How to reproduce it in Drupal? (All old URLs should work for the new site, too -- though I realize that multiple URLs for the same article are believed to be bad for SEO).
One way to do it would be via multiple path aliases, but (1) I would like to avoid triplicating the number of records in the url_alias table, and (2) how to control which one of the three URL's of a node is displayed in views for each subsection?
I guess it could be also done via url rewrite rules added to .htaccess;
could you please help me with a RewriteRule syntax for this (so that each node is accessible as /en/resources/books/123, /en/topic1/resources/books/123, etc.)?
(Should it be done before the "RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]" rule?)
Also, I wonder how to arrange each topic prefix to be part of URL in subsection-based views...
Any ideas would be appreciated.
Thank you!
Comments
I would recommend that you
I would recommend that you NOT use mod_rewrite to rewrite your URLs. If you need /en/resources/books/123 to be themed differently than /en/topic1/resources/books/123, then rewriting your URLs is going to cause you more problems as Drupal won't be able to tell what URL was requested and you won't have any way to tell which theme to use. I don't have a canned solution for you. I would try to use taxonomy and pathauto to do most of the work. I think you'll have trouble getting the multiple URLs to work, so I would write a little custom "glue" that would allow a "topic" taxonomy prefix to be included in the URL as well.
Thank you
Thank you for your suggestions Jason.
I think taxonomy-based solutions could be difficult, because most articles belong to multiple categories and should be available under multiple aliases.
By the way, it occurred to me that it might be quite helpful to have a module or another tool able to do path aliasing "on-the-fly": imagine you have a site with some twenty thousand nodes; you need to add twenty thousand records to the url_aliases table to alias each node/nid as, say, article/nid; on the other hand, this rule could be described by a single line of URL rewrite rules - and you'd need to add just one more line instead of twenty thousand more records if you need to see your nodes also as content/nid...
a puzzle.
Interesting challenge.
I don't know enough about how many topics or different patterns you are talking about here, BUT if the urls are as regular as your examples, I can see how a very small module can be designed to capture all requests under /en/topic1/* and realize that you are really wanting /en/[*]
A simple internal lookup would retrieve THAT node and render it in THIS page.
Most of the other Drupal bits like themes and blocks would be none the wiser, as they trigger on the actual request URL. So you have your result there.
This module would have to load early, so as to set the context for any context-sensitive bits ... and there may be some odd side-effects, but in general, it can be done.
I'm saying this because I do know how Drupal works at that level, (and the gotchas), although it doesn't look very intuative from the outside. I've done stranger things with wrapper modules to legacy content :-)
A bonus is that you don't even need to fill up the alias table, as the shadow pages are dynamically resolved.
Gotchas include node-edit menu and path editing - you can only work on the base copy. ... which was going to be a problem for you anyway.
You can still build menu structures to refer to the ghosts ... but you have to do it through the menu interface, a bit blind.
You will not get an edit tab on the ghosts, only the canonic ones. Well you could, but it would hurt a bit more.
Adding multiple menus and multiple aliases into the node edit form would be an odd feature request, but possible. Best not tho.
... there may be more to it under D6 than D5 ... but that's my approach :0)
.dan.
if you are asking a question you think should be documented, please provide a link to the handbook where you think the answer should be found.
| http://www.coders.co.nz/ |
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Thank you for your comments
Thank you for your comments Dan.
Zero-level task is to make all alternative URLs work, and I guess it could be relatively easy with a module you are talking about.
Availability of edit tabs for ghosts? Hmm, it's an interesting question I never thought of...
I realize that building "ghost" menus and views for subsections should be a more difficult thing - I think it would be nice if Views had sort of a "computed field" output tool, so that you could display some function of a field value instead of the real value - e.g. a URL with a prefix instead of the real URL.