Just when I thought I had gotten my head around EE URLs, templates, and weblogs, I ran into a new problem that’s left me a little puzzled.
I’m putting together a site with a few weblogs and a few template groups. I’m using a weblog->template group naming association to keep things organized for myself and so my site URLs make sense. The front page of the site will display content from all the weblogs, in a single blog-style reverse chronological format. This part works fine.
Where I’m running into trouble is with my review section. I’m writing reviews for books, music, etc, and had envisioned a URL structure like this:
<a href="http://www.example.org/reviews/music/">http://www.example.org/reviews/music/</a>
<a href="http://www.example.org/reviews/books/">http://www.example.org/reviews/books/</a>After reading all about how EE uses URLs and templates, I created a “reviews” template group and templates named “music” and “books”, thinking this would take care of it. The problem I’ve run into now is that I don’t know how to tell EE to use the appropriate template when generating links on the front page. All the entries appearing on the front page want to use the “main” template group that my main index template lives in. I’m able to specify the correct template groups by writing links like this in my index template:
<a href="/{weblog_short_name}/{url_title}">{title}</a>This is where you see how sharing a name between weblogs and template groups keeps URLs logical. The problem is that all URLs use the index template in the specified template group. This works fine for most of the site, but means I can’t use URLs like the above for the book and music reviews. Hard-coding the template in the URL works but I can’t do this because this code is displaying content from multiple weblogs, not just the reviews.
I think I could do something by creating categories named music, books, etc, and checking for them when constructing the links, but this seems convoluted and unnecessarily complex, especially given that posts may be in multiple categories.
I feel like just when I thought I had figured out template groups and page templates I realize that it doesn’t actually work the way I thought.
The funny part is that I’m porting over a site that currently uses URLs like the above but without “reviews” in the path. I added that after figuring out that EE requires template groups in URLs and deciding that creating separate groups for books, music, etc, is somehow fundamentally missing the point.
So help me out. Is there a simple way to do this that I’m missing? How are these page templates normally used if there’s no easy way to automatically generate permalinks using them?