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.

Newbie site structure using channels and categories

February 04, 2012 8:52am

Subscribe [4]
  • #1 / Feb 04, 2012 8:52am

    thebluecube

    11 posts

    Hi all.

    For the past week I have been working hard at learing EE, and so far love it!

    However I am worried I have set up my site with the wrong strcuture between the Channels and Categories, and I do not know how to progress with my code. So any help here is much appreciated!

    What I am trying to achieve:

    - One template
    - Two pages (Home and About)
    - Different list of posts in each page, populating the same template design.

    You can see how I have tried to show this in my attached jpg. The diagram shows that we have 2 pages, both using the same template, but I have now realised that I can’t pull in specific entries based on the way they have been assigned in the admin panel categories.

    Can anyone suggest a better way for me to set this up?

    Many thanks.

  • #2 / Feb 04, 2012 10:04am

    Boyink!

    5011 posts

    I’d split them up into separate channels, and use two templates (probably the index templates of two template groups).  Shared code can be chunked out into either snippets or embedded templates, or if the thought of having one template is key then look to use conditionals based on url segment to choose between channels.

  • #3 / Feb 04, 2012 5:10pm

    John St-Amand

    865 posts

    I agree with Mike on that. If the Home and About lists of posts are distinct from one another (i.e. an item doesn’t cross over and appear in both) then separate channels would likely be your simplest and most direct route.  I tend to stay away from categories unless I absolutely need them - categories are really just filters of the content in question, narrowing your field of view, effectively.  I find this concept tends to confuse even some more sophisticated clients unless the intent is extremely clear - like categories of a large section like a blog.  If you chunk the templates the way Mike is referring to, all the elements they share would each be in their own snippet, global variable or embed, leaving the main difference between the two templates the loop of your entries.

    I tend to prefer to use separate templates for things like this if only to be ready for the future.  If I (or my client) suddenly decides they want some other content added to the template that is distinct one from the other, then having it all in one template progressively gets trickier, with more conditionals needing to be in place in the template to tell EE what to display when.  When in a distinct template, I have no such limitation, and so even if the templates start out almost completely identical to one another, i know that i can easily add distinct features to each without complicating my conditionals.  And when you chunk your content elements effectively, your DRY approach is still easily maintainable.

    Hope that helps.

  • #4 / Feb 05, 2012 5:47am

    thebluecube

    11 posts

    Thanks guys. I will progress the build as per your recommendation.

  • #5 / Feb 05, 2012 8:50am

    thebluecube

    11 posts

    Hi again

    I’ve been looking into this and I don’t think this approach is going to work. In my first post I didn’t mention that this template/layout is going to be used on lots of pages within the site. At least 15 pages will use the template, each to be populated with different content in the posts that relate to the individual pages.

    Do you think your suggested approach would work in this situation?

  • #6 / Feb 05, 2012 9:36am

    John St-Amand

    865 posts

    It’s tough to know for sure - it depends largely on the nature of the content from one “page” to the next.  Certainly our advice was based on your originally suggestion that it was the same template for two distinct sections.  But if there’s a lot of sections all to use the same template, then it can still work but there may be a different approach available as well.  Can you describe the nature of the content in more detail?  What’s different and what’s the same between them?

  • #7 / Feb 05, 2012 5:22pm

    I think it really makes things simpler to structure your templates basically according the the EE url parser: /template_group/template. The index template will also accept a segment2 that doesn’t link to a template, so you can use it to break down a channel at level 2 instead of 3.

    You can also make use of the segment tags to display content from different channels or categories as needed:
    {exp:channel:entries channel="news" category="{segment3}” limit=“10”}

    There are just so many ways to do things, that’s why it’s tricky without knowing a good amount of detail to suggest a direction to go in. I haven’t used EE that long, but I find the flexibility great!

  • #8 / Feb 05, 2012 6:51pm

    Boyink!

    5011 posts

    Hi again

    I’ve been looking into this and I don’t think this approach is going to work. In my first post I didn’t mention that this template/layout is going to be used on lots of pages within the site. At least 15 pages will use the template, each to be populated with different content in the posts that relate to the individual pages.

    Do you think your suggested approach would work in this situation?

    In a sense, pages don’t matter.

    1 template + 1 channel + 15 entries in the channel == 15 pages.

    Or 5 templates + 3 channels + 5 entries in each of those channels == 15 pages.

    If you’re thinking that you need one template per page that’s not - usually - how EE works. 

    Don’t let your template structure dictate your content structure.  Get your content figured out so that one channel = one content type,  then flow those content types out through whatever templates it takes, knowing that EE gives you plenty of ways to have many templates but still be pretty DRY.

  • #9 / Feb 07, 2012 8:20am

    thebluecube

    11 posts

    Thanks, I have worked through this now and have worked out a solution that seems to be working for me!

    Another question that I have relates to loading content into an entry URL. For example you can see here I have an entry page with 2 links in the left column. When the links are clicked I need to work out how to show the content for that entry in the page template:

    http://tgls.thebluecube.com/know-how/

    The left menu is created with:

    {exp:channel:entries channel="know_how" limit="100" dynamic="no"}
    {title}
    {/exp:channel:entries}

  • #10 / Feb 07, 2012 8:48am

    Boyink!

    5011 posts

    Well, first lets get some terms straightened out.  An entry_url is actually part of the content - url_title is a default field in a channel to which you’ve added channel fields to.  Together all of those fields comprise the content for a given entry.

    Your links look ok - assuming you have an article template in your know_how template group, and that template is coded to display entries and does not have dynamic turned off (so EE knows to pull the right entry based on the URL).

  • #11 / Feb 07, 2012 8:53am

    thebluecube

    11 posts

    OK Thanks!

    I think the problem is that I don’t have a template in the know_how template group that displays entries. But thats the problem… I don’t know how to make the template and set the entries to use it.

  • #12 / Feb 07, 2012 8:59am

    Boyink!

    5011 posts

    From an EE perspective all you need is an article template with another channel:entries tag.  Since you’ve linked to it with a valid url_title it will pull just the one entry and display it however you mark it up.

  • #13 / Feb 07, 2012 9:09am

    thebluecube

    11 posts

    mmm, still trying to figure out what I’m doing wrong…

    Here is my page but it is still looking like the site home page for some reason.
    http://tgls.thebluecube.com/know_how/article-2

    I have created an article template and am trying to pull content using:

    {exp:channel:entries channel="know_how"}

    {title}

    {article}
    {/exp:channel:entries}

    but still not working??

  • #14 / Feb 07, 2012 9:23am

    Is the template called article-2? If not, then the default/index template for the group is used.

    And is this template inside the template group know_how?

  • #15 / Feb 07, 2012 9:25am

    thebluecube

    11 posts

    Thanks, that was exactly it… I wasn’t using a template therefore the index was being used. Don’t worry I’m learning more and more each day!

    thanks guys

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases