问题
I'd like to have a hierarchical URL structure in my site. Something on these lines:
- tutorials
- javascript
- jquery
- javascript
There should be a page at each level (tutorials
, tutorials/javascript
and tutorials/javascript/jquery
). Obviously, using Taxonomies would help me organize my content in this manner, but how do I get Autoroute URLs generated for this scenario?
Bertrand Le Roy made a comment on this SO answer about using taxonomy terms as pages but it still doesn't seem to create the right URL structure for me. Am I missing something? Is there something specific I need to configure or enable to make this happen?
Are there any other approaches I can look at?
I was thinking of specifying the default route as something like {Content.Fields.Page.TaxonomyName}. It appears that this isn't really possible right now according to this bug report.
回答1:
Here's an approach that seems to work without having to use taxonomies:
I added a Content Picker
field called ParentPage
to the Page
content type and updated the Page
's Autoroute default to
{Content.Fields.Page.ParentPage.Content.Path}/{Content.Slug}
Now in each page I get to pick what the parent page is and the URL is constructed how I expect it. From what I remember of working with WordPress, I think this is pretty close to how it allows you to do this parent page thing, too.
来源:https://stackoverflow.com/questions/13540933/whats-the-recommended-approach-for-hierarchical-urls-in-orchard