Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Category_url_title in segment 1 on a directory listing view page #29

Open
ghost opened this issue Jan 22, 2016 · 3 comments
Open

Category_url_title in segment 1 on a directory listing view page #29

ghost opened this issue Jan 22, 2016 · 3 comments

Comments

@ghost
Copy link

ghost commented Jan 22, 2016

Our site has a directory channel with entries that are organized by category. We would like to be able to link to the individual listing with the url as such: http://domain.com/category_url_title/url_title

Currently, we have created template groups for each individual category and are using the index page within each template group to display the listing. We are hoping there is a better way to do this with resource router but need some assistance in setting it up.

I have been looking at this post thinking that it could help in this situation but am still not able to find a solution: #19

Thanks for your help!

@rsanchez
Copy link
Owner

You should be able to do this:

$config['resource_router'] = array(
  ':category_url_title' => 'site/_category_index',
  ':category_url_title/:url_title' => 'site/_listing',
);

In your site/_category_index you will have the following variables available to you:

{route_1_cat_id}
{route_1_cat_name}

In your site/_listing template you can use {route_2} to get your url title.

@ghost
Copy link
Author

ghost commented Jan 25, 2016

Thanks! This is working for us, however we arent using the template _category_index for anything. Can you explain what it would be used for to give us a little more understanding of the use of this template?

@GDmac
Copy link

GDmac commented Feb 13, 2016

That would be when hitting cat only (no entry)
e.g. http://example.com/category_url_title/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants