0

I'm building a site that has 20 city markets using a Markets Channel. Each market will have it's own version of a page, so austin/store, nyc/store, austin/about, nyc/about, etc.

I also have a National market that is the catch all version of a page that does not have a market in the first segment, so /store, /about, etc.

The thing is that if we're using the National market channel to display a page I don't want that segment in the URL. It should not be national/store, national/about. A visitor should never see a market in the URL unless it's on a proper market like austin or nyc.

My question is, can I use resource router to accomplish something like this and how would I go about setting it up so I don't have to create two versions of a route, one for national and one for proper markets? And then on top of that only displaying segment_1 if it's a market besides national.

1
  • I guess what I'm thinking in using Resource Router is checking segment_1 if it's a valid URL Title for a Market Channel Entry. If it is then set a global using the URL Title of the Market. If not then set a market global to "national". Jul 13 '15 at 16:03
1

I can't tell you how Resource Router can do this, but I can tell you how standard Template Routes can do this.

Make templates or template groups for /store, /about, etc. (Doesn't really matter where they are or what they're named, since you'll be adding routes to them anyway.)

Then add a route for each of those templates like so:

store/{market:alpha}

about/market:alpha}

Etc.

Leave Segments Required set to "No".

Then in your template, use the channel:entries tag like so:

{exp:channel:entries channel="markets" {if segment:market}url_title="{segment:market}"{if:else}url_title="national"{/if} dynamic="no" limit="1" require_entry="yes"}

Does that do the trick?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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