Use regular news ‘news/index’ template:


Use special ‘news/special-story’ template:

  • I would suggest breaking this into two questions so you can mark a correct answer for each.
    – UltraBob
    Dec 5 '12 at 3:09
  • @UltraBob done, the second question is over here: expressionengine.stackexchange.com/questions/1136/…
    – Lea Hayes
    Dec 5 '12 at 3:12
  • You probably want to go mark one of these answers as correct to let people looking at this in the future know which answer worked best for you. To do that, click on the checkbox under the up and down vote buttons.
    – UltraBob
    Dec 6 '12 at 0:51
  • @UltraBob In this scenario I think that my answer is correct, but I wouldn't have come across this without the help of both you and the other question that I posted. I am unable to accept my answer until tomorrow because StackExchange wont let me. thanks again for your help
    – Lea Hayes
    Dec 6 '12 at 1:35

I'm not completely clear on what you want to do here, but I'll give it a shot. I'm assuming you want to have your regular news with any url_title show up using the index title, so /site/news/regular1 and /site/news/regular2 would both use the site/index template. I believe you can accomplish that much by default, you just need to make sure your template has the code in place to read the url title and pull the appropriate content.

The second one is a little unclear as to what you want to accomplish? Do you want to have a special template for each special story or one special template for all special stories?

A special template for each story: Just create the template with the appropriate name and make sure it has the code to read the right content, and away you should go.

A special template for all special stories: Look into the pages module for this, or you can have a toggle of some kind in your channel fields that the main template would look at and determine which design template to embed.

Let me know if this answers your question, or if it seems like I'm misunderstanding, please edit your question to clarify.

Update: Based on your clarifications I built a little proof of concept with one of my existing channels and a new template group called testa. Here are the two templates:


{if segment_2==""}<ul>{exp:channel:entries channel="announcements"}
{exp:channel:entries channel="announcements" url_title="{segment_2}"}<h1>{title}</h1}

and here is a brief sample of output from /testa/ (note I don't have the equivalent of your /site/ folder so in your case it would be segment_3)

enter image description here

If I visit /testa/islamic_finance_report I get the title and English body of that page, until I add the islamic_finance_report template in the template group:

{exp:channel:entries channel="announcements" url_title="islamic_finance_report" limit="1"}

Now visiting that same url loads up the Japanese title and body for that page.

Hope that helps.

  • Yes /site/news/regular1 and /site/news/regular2 work pretty much with the default settings. But say for example I want to provide a custom template for a specific content. Say where content_id == 24. In WordPress this would be achieved something like "post-24.php" or even "post-something-special.php". How would this be done with EE?
    – Lea Hayes
    Dec 5 '12 at 3:28
  • I think you could just simply create a template called whatever you want the url to be in the news template group and them make sure the link for that entry points at site/news/your_selected_address I would suggest using url_title for that, but it could be anything.
    – UltraBob
    Dec 5 '12 at 3:44
  • I think that I have found my solution for this part of the problem thanks to the response on my other question. I have posted the working solution as an answer here so that you can see what I was asking (though perhaps not in the clearest of ways). Please feel free to edit my question to improve its clarity. And thanks very much for taking the time to help, very kind.
    – Lea Hayes
    Dec 5 '12 at 3:56

Okay, the following seems to solve two problems:

  1. It allows me to provide a different template for the category listing and for an individual news item.
  2. Looking at the URL segment I can perform some custom template routing.

Here is my template "news/index":

{if segment_2 == 'category' || segment_2 == 'archives' || !segment_2}
{if:elseif segment_2 == "special-story"}

This has the undesirable effect of adding whitespace in front of the page DOCTYPE, but I cannot see an easier way to avoid this (any ideas welcome!)

  • Yes that'll work, I realized when I was editing that I should have mentioned the need for segment variables. With my answer you don't actually have to specify your special templates ahead of time in the template conditional, just create the template. You can avoid the whitespace just by cramming all of those conditional expressions together without any whitespace between them.
    – UltraBob
    Dec 5 '12 at 4:08
  • Though messy, it seems that the special {!-- --} style comment can be used to avoid the whitespace also. I am tempted to just put the DOCTYPE at the top of this template because I read that it is bad for user agent compatibility. Thanks again for your help
    – Lea Hayes
    Dec 5 '12 at 4:12
  • I'm assuming you don't need to recreate the entire page from DOCTYPE on down for each special template though right? I would guess you have a large portion or stuff, possible all the way down to your content container at the top and from the end of your content container at the end. Why not just embed the bit that you need to embed conditionally? i.e.: beginning of html page -> embed logic -> end of html page
    – UltraBob
    Dec 5 '12 at 4:18

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.