ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Have an overview page & subpages sharing common url base?

August 12, 2011 10:20am

Subscribe [2]
  • #1 / Aug 12, 2011 10:20am

    Sorry I don’t quite know how to explain this.

    I want to have all my news articles listed at /news.

    But I’d also like to have individual articles resolve as /news/article1, /news/article2 etc

    I tried making a template group called ‘news’ and setting the index up as the main list page, which does work ok for /news.

    I’ve got my news articles in a ‘news’ channel, but when I try to go to /news/article1 etc, it just shows the /news page, despite the url displaying as /news/article1.

  • #2 / Aug 12, 2011 10:43am

    I think I just figured it out for myself, if this is the correct way.

    I made my news template group ‘index’ template show the individual news item.

    Then set up a page at /news and linked it to an ‘all’ template.

    It seems to be working so far.

  • #3 / Aug 12, 2011 11:38am

    glenndavisgroup

    436 posts

    Hi businessessentials,

    Try using:

    <a href="http://{title_permalink=">{title}</a>

    for your link to the news item.

    Mike

  • #4 / Aug 12, 2011 11:53am

    I’ve got that bit working.

    Now I’m having trouble with the /news page. I’m trying to display all the entries in the news channel, but it’s not showing anything. The same code works fine on the home page, but not here.

  • #5 / Aug 12, 2011 12:38pm

    glenndavisgroup

    436 posts

    What version of EE are you running and can you post your code?

  • #6 / Aug 12, 2011 12:49pm

    2.2.2

    Code is nothing fancy..

    {exp:channel:entries channel="news" limit="5"}
    {title}
    {excerpt}
    <a href="http://{title_permalink=news}">Continue reading »</a>
    {/exp:channel:entries}

    So, to reinterate..

    I’d like to work out the structure as follows:

    /news = list of all news articles

    /news/article1 etc = individual articles

    I’m just not sure how to best structure things to make this work. It’s like the /news is somehow overriding things. Is this supposed to not be allowed in EE perhaps?

  • #7 / Aug 12, 2011 1:19pm

    glenndavisgroup

    436 posts

    On your /news/index page you can use the code you posted to display all the news items. One thing I recommend doing is adding the status=“open” to your channel entries tag. This will guarantee that only news items with the open status will display.

    To display the details of a single news item I usually create a “view” template in my news group and use that to display the detailed info. So you would have /news/view/article1. In the view template you would have something like the following:

    {exp:channel:entries channel="news" limit="1" status="open"}
    {title}
    ...
    {/exp:channel:entries}

    EE will automatically display the requested news item for you. I hope that helps.

    Mike

  • #8 / Aug 12, 2011 1:56pm

    Ok, thanks that got me going but then I just somehow blindly stumbled upon the below thread:

    http://ellislab.com/forums/viewthread/153839/#744711

    Post #6 there seems like a good idea so I will give it a try.

    Also, regarding specifying status, in the User Guide I read this:

    “Entries with a status of Closed will not be shown unless explicitly stated in the templates. Entries with a status of Open will always show unless explicitly stated in the templates.”

    So it sounds like there is no need to require the status to be open, as that is built in by default. Perhaps that was a specific requirement of earlier versions though?

  • #9 / Aug 12, 2011 2:23pm

    glenndavisgroup

    436 posts

    I like that solution better 😊. I’m going to change my code to use the same thing. Thanks for pointing that out 😊

    Regarding the status you are correct. EE by default will only display open statuses however I do like to specify it just in case and it’s visibly more clear as well. But that’s just me.

    Mike

  • #10 / Aug 12, 2011 2:32pm

    As mentioned in that thread, I found out it stuffs up with pagination. So now I’d trying to figure out how to use Switchee, but I can’t figure out how get that working with pagination either yet!

  • #11 / Aug 12, 2011 2:45pm

    I found this, which seems to do the trick, yay!

    {exp:switchee variable="{segment_2}" parse="inward"}
    
        {!-- Index page. Match empty string or pagination --}
        {case value="#^P(\\d+)$#|''"}
            {embed='news/list'}
        {/case}
            
        {!-- Single entry --}
        {case default="yes"}
            {embed='news/view'}
        {/case}
        
    {/exp:switchee}
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases