Meanwhile I gave the parameter-based rewrite system a try again. I have:

routers = dict(
  BASE  = dict(
      default_application='color_book',
      default_controller = 'colors',
      default_function = 'show_color_page',),
  color_book = dict(languages=['en', 'it', 'fr', 'de'], 
default_language='en'),
)

In contrast to my initial idea it should be possible to pass my color and 
color variation categories as args to the URL function to build my desired 
URL structure and let the parameter-based routes.py just cut off the 
application, controller and function names instead of replacing them using 
a pattern-based routes.py file.

This works half way: Above defined application and controller names are 
left out as soon as the routes.py is loaded. And I can access my pages 
without app and controller name in the URL. But leaving out the function 
name only works for the index page:

http://127.0.0.1:8000/ (index page loads correctly)

The original URL 
(http://127.0.0.1:8000/color_book/colors/show_color_page/title-of-the-page 
of other pages cannot be replaced by entering
http://127.0.0.1:8000/title-of-the-page (invalid request)
I have to enter: http://127.0.0.1:8000/show_color_page/title-of-the-page to 
access that page.

Any idea why?



On Monday, September 2, 2013 3:20:05 PM UTC+2, Anthony wrote:
>
> What does your routes.py file look like now?
>
> On Monday, September 2, 2013 2:22:38 AM UTC-7, xelomac wrote:
>>
>> Hi everybody,
>>
>> after playing around with routes.py for a while I wonder if what I want 
>> to do is possible at all. I want to rewrite the URLs shown to the visitor 
>> after clicking a menu link in the following way:
>>
>> Lets say I built a site that deals with colors. My menu shows base color 
>> links like red, green, blue on the top level and variations of the the base 
>> colors on the next menu level. My app would be named "color_book" my 
>> controller "colors" and the the function showing the pages 
>> "show_color_page".
>>
>> After clicking the submenu item "light-blue" under the parent menu-item 
>> "blue" I would normally see an URL in the browser like:
>> http://my.domain.com/color_book/colors/show_color_page/light-blue
>>
>> But I want to rewrite the URL to: http://my.domain.com/blue/light-blue
>>
>> Accordingly a page with the menu location "red > dark-red" should be 
>> presented with: http://my.domain.com/red/light-red
>>
>> I thought that a pattern-based routes.py could be configured to do things 
>> like that. But I've only had success with rewriting URLs manually entered 
>> in the browser's address field so far- but not with internal links.
>>
>> Is there an example for my use case somewhere?
>>
>> Thanks for any help!
>>  
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to