4

I'm trying to create a category-like hierarchy using only Structure, but am having issues with the requirement of each entry having a unique url_title.

For example...

Category1
  Sub1
    Item1
    Item2
    Item3
  Sub2
    Item4
    Item5
    Item6

Category2
  Sub1
    Item7
    Item8
    Item9
  Sub2
    Item10
    Item11
    Item12

The issue is that Sub1 and Sub2 have to have unique url_titles, which effects the URL.

I realize this is not a Structure-only issue, it's essentially EE's limit, but the Structure tree in the CP - organized as above - is so easy for clients to manage, I prefer to go this way instead of using categories. And, I can simply use {exp:structure:nav} to output the entire listing.

Is there a way to allow Sub1 and Sub2 to exist as '/sub1/' and '/sub2/' but be used throughout the Structure tree, across multiple Categories (ie: Category1, Category2, Category3, etc.)?

3 Answers 3

9

In EE, all pages require unique URL Titles. However, in Structure, if the pages have different parents, they can share the same Structure PAGE URI.

In your case, so long as you are using the full Structure URIs to display the pages, you shouldn't have any issue reusing "sub1" and "sub2" in each category tree.

So while EE will create unique URL titles for each entry, such as sub1, sub1-1, sub1-2, sub1-3, etc, it won't matter, because in your templates, you will use dynamic="no", and simply allow Structure to render the page based on the full Structure URI. For example, your rules would look like:

/category1/sub1/page-title/

/category2/sub1/page-title/

/category3/sub1/page-title/

Should work fine, and without Freebie.

Let me know if you need clarification.

  • Ira @ The Red Eye
2
  • So, you're saying that it's the Structure Page URL that is used in the URL and it can be different than the entry's URL Title? I thought they both had to be the same?
    – dbigca
    Commented Dec 11, 2012 at 19:14
  • 1
    Correct, the Structure Page URI does not need to match the EE URL title. By default they are the same, but you can change either of them. And the same Structure URI can be used any number of times on the same site, since Srructure is smart enough to know that they have different parents (therefore, different full URLs).
    – ira42
    Commented Dec 11, 2012 at 22:05
1

I had a need for this same usage. Here is what I ended up with that really helped in my situation. With mine, there were multiple markets which had similar software packages. They wanted to :

  • Distinguish the markets and keep them separate
  • List the software by the same name in the URL (Which was the entry)
  • Maintain a single entry for all changes to copy for marketing

I created a fieldtype that was a simple checkbox which was named, in this case 'Universal Product?' => 'prod_universal', which when selected, would trigger the embed of the common entry.

I had to rethink my main template and create a router of sorts. I had a section for the menu(nav), body, and footer. In the body, it would start like this:

<!-- MAIN BODY -->
    {if prod_universal}
        <!-- Universal Product -->
        {embed="group/template" universal_title="{title}" entry_id="{entry_id}"}

This then embed the template needed for that entry. (Nothing major, just handled differently)

I was then able to use the Structure navigation as normal like:

{exp:structure:nav_sub start_from="/market" css_class="subnav" status="not No Nav"}

But when the regular (routing) template saw that the entry was universal, it was routed through the other template pulling the common entry.

As far as the same URL issue, that is all handled by the URL building and routing operations done from within Structure. the normal EE URL's can be whatever1, whatever2, whatever3... Just click on the structure tab and name them the same. Now they will traverse the same in the nav bar and read the same in the navigation.

Hope this helps.

2
  • Interesting approach for your situation. See my comment on @ira42's answer - so you also use unique Structure Page URLs?
    – dbigca
    Commented Dec 11, 2012 at 19:16
  • Yes. The structure add-on allows you to have "like" URL segments.
    – W3bGuy
    Commented Dec 12, 2012 at 0:11
0

I'm not quite sure what you're trying to do - but I suggest you have a look at this add-on: Freebie http://devot-ee.com/add-ons/freebie - a lot of devs use this to make the url structure more flexible.

1
  • Freebie would be good if I were using categories to set the URL, which I'm not. I'm trying to allow for multiple copies of certain entries to exist so the site's nav can be replicated in the CP, within Structure.
    – dbigca
    Commented Dec 11, 2012 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.