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.

Embedded Templates and categories

September 01, 2011 2:57pm

Subscribe [2]
  • #1 / Sep 01, 2011 2:57pm

    Neil Evans

    1403 posts

    I have a master template - /site/page/
    On which i display a single entry /site/page/my-entry/

    Lower down on that template i have another embedded template that displays a list of events. Simple enough, a single entry tag wraps the whole of the first template, and the embedded template allows for another entries tag to display the events.

    Now, in my events i have categories - so if i want to restrict these events by category, i need to put something in the URL, whether that be C1 or or /category/catname/ or whatever.

    However, in doing this, the single entry master entries tag, will not display. I cannot turn off dynamic, because it is getting the URL_title from the url to identify which page to display. SO i understand that this is not displaying because it is using dynamic to also check that entry is in a category specified, it is not, so fail.

    So my question is - how can i display a category refined list on a page, which also has a single entry on it?

  • #2 / Sep 01, 2011 4:18pm

    Lisa Wess

    20502 posts

    Hi nevsie,

    You would use dynamic no. 

    But… you lost me a bit in your explanation. Do you have the channel entries tag surrounding the embed, then?

    I think in this particular case it would be especially helpful to see your whole template.  Can you copy/paste that here, attach it, or even put it on pastie somewhere for us to view?

    Thanks nevsie!

  • #3 / Sep 01, 2011 4:33pm

    Neil Evans

    1403 posts

    Hi Lisa,

    Okay, i’ll see what i can do to explain further with examples… By dynamic no would mean that the single entry would not load… let me illutrate below:

    Master template (/site/page/)

    {exp:channel:entries channel="pages" limit="1" require_entry="yes" dynamic="yes" }
        <h1>{title}</h1>
        {pages_content}
    
    {embed="common/.subtemplate"}
        
    {/exp:channel:entries}

    Sub template (/common/.subtemplate/)

    {exp:channel:entries channel="events" }
        <h2>{title}</h2>
    <p>    {pages_content}<br />
    {/exp:channel:entries}

    I have massively stripped out the templates to keep them simple.
    In the master template, yes i need the entries tag to wrap the whole template for various elements. Hence why i have embedded the second template so i can have another entries tag in that.

    So i have the URL:
    mydomain.com/site/page/my-page-url-title/

    When this is entered i want to use that url_title to load the right content from the pages channel. I then want the sub template to display all entries, not limited by the url or category, etc. This part works fine.

    However, when i want to limit the subtemplate events channel by a category - if i enter this into the URL, because the main template is dynamically loading its entry from the url_title, then it also applies the category to this as part fo the dynamic conditions. As such because my categories relate to events and not pages, no entry is displayed.

    So if i turn dynamic off/no for the main templates entries tag - then this will of course not process the url_title to identify the entry, and no page will load either.

    Therefore, my query: is there a logical way around this? (i.e. dynamic=“category_off” so it only disables that dynamic part)

    I think working with categories is the most infuriating part of EE (excluding all the bugs), it is almost completely crippled, and useless!

  • #4 / Sep 01, 2011 4:46pm

    Lisa Wess

    20502 posts

    nesting your channel entries tag like that is not a good idea.  Let me explain:

    1.  Variable conflicts will ensue.
    2.  More importantly you’re going to do a cascading loop between your channel entries tag.  If you were passing variables to the inner embed this would be limiting; but you’re not.

    As a quick test, since you’ve already minimized the template - if you move your embed outside of the channel entries tag, does this work the way you need it to?

  • #5 / Sep 01, 2011 4:47pm

    mattgreen110

    46 posts

    I could be wrong nevsie, but it seems like you are trying to pull in content from the url for both categories, and an individual entry id that are not necessarily related to one another. You might need a different approach. you cannot pull in dynamic content for two different parts of your template using the url segments, it seems like one or the other. Or use one, and then find a way to relate that to the other.

  • #6 / Sep 01, 2011 5:00pm

    Neil Evans

    1403 posts

    Hi All,
    Lisa - i understand your caution about the methods in use… but in the master template there is a limit=“1” so there will be no cascading loops.
    Passing variables down - can be done, even if i was cascading loops and not sure how this would be limiting, but not of concern here as it is limited to 1 entry in the main template.

    Matt - Yes effectively you are correct. This is kind of my point about this enquiry.

    I want to know if the dynamic=”” parameter is only an on off switch, or whether this actually has useful functionality like dynamic=“entry_yes|category_no”. So in that example we can actually have two dynamic variables in the URL, but selectively on the entries tag choose which one to use. As opposed to what i believe is the current all or nothing approach.

    And more importantly, as i am pretty sure the above is not possible… is there any obvious workarounds?
    For example i am currently fudging this by using the following URL (manually created)
    mydomain.com/template_group/template/url_title/9/

    The idea being that the group/template/title part dynamically loads the right entry for main pages template. I then feed segment_4 to the subtemplate, which has dynamic completely turned off, and i inject this into the category to be used. This works fine, but is a slap in the face for SEO. Ideally i would like to use the category url_title variable in the same way - but again crippled.

    So if anyone has any thoughts on workarounds… i would be gratefull. A couple of thoughts:
    1. I do not want to create a custom template just for this section with the pages entry id hardcoded in. As although this would work - it kind of defeats the purpose of a dynamic CMS driven system. I would have to tell the client to either duplicate the template, or modify the template if they wanted to create another similar page, changed the entry, etc.
    2. My main pages entry tag does wrap the whole template for various SEO purposes, and as such i do need that functionality. Yes i could split this into seperate tags wrapping each place it needs to be output, but this is way more in-efficient - so again less ideal.

    Thanks, N

  • #7 / Sep 01, 2011 5:29pm

    Lisa Wess

    20502 posts

    dynamic= is an on/off switch.

    You can turn dynamic off and then use parameters to create your own URL dependencies.  for instance, url_title=”{segment_2}” etc, would be a simple, straightforward one.

    Make sense?

  • #8 / Sep 01, 2011 5:34pm

    Neil Evans

    1403 posts

    hi Lisa,
    Thanks that is exactly the clear thinking i needed - not sure why i thought to stuff the category id as a value into the entries tag and not the url_title to the main page entries tag.

    Kind of the reverse of what suggested above and was doing. Should help.
    Is there a similar parameter for categories, or am i stuck with only being able to pass category_id? And if i can do this with categories does it work pipe separated like i can with ID’s?

    Also - any news of when categories are going to get some love from the Dev’s? It seems to have beed requested a lot!!!

  • #9 / Sep 01, 2011 5:43pm

    Lisa Wess

    20502 posts

    Not sure on when categories will see improvement, did you have specific requests?

    These are really the two category parameters, which are both pipe separated.

    category=“1”
    category_group=“1”

    Some folks also use Low’s Seg2Cat for some interesting approaches that might help you in this case?

  • #10 / Sep 01, 2011 5:51pm

    Neil Evans

    1403 posts

    Hi Lisa,
    thanks i guess only ID’s will work unless i get Lows plugin to fill this gap! I guess that is one request already!
    I would suggest having a read through the feature requests forum with a search for categories - lots of whining and requests there (myself included).

    Even have a look at devot-ee for al the add-ons needed to fill the gaps.
    Primary example is why you have not integrated the file manager into the categories image field i have no idea - its like categories were completely forgotten!!! Hence my mention of Iain’s Catshit plugin further up:
    http://iain.co.nz/software/docs/catshit

    I used to do feature requests, and will do with really big/important ideas. But to be honest at this point in time you barely have time to sort bugs let alone make major changes. So i will wait until EE2 is stable(r)!

  • #11 / Sep 01, 2011 6:06pm

    Lisa Wess

    20502 posts

    I read the feature requests forum about 50 times a day; but I’m more interested in what you specifically are looking for.  I know what I want, and I feel like I have a good understanding of what the community at large wants there, and those two things mesh nicely. =)

    Thanks nevsie!  At this point, are you comfortable forging a solution from the ideas in this thread?

  • #12 / Sep 01, 2011 6:18pm

    Neil Evans

    1403 posts

    Hi Lisa,
    glad your getting in there, i honestly feel that with the mass of requests there is too much for it to make any clear logical sense.

    In short, my general feelings towards categories are “avoid at all costs” within EE. Everytime i have used them i have needed to write custom plugins to get them to function in ways that other CMS’s seem to nail first time - the other cms’s just miss all the other good parts of EE!!! Mentioning the lack of file manager integration is just the tip of the iceberg as this really does make it feel like an unfinished part of EE.

    The addons i typically write relate to 3 main things with categories - better and more flexible output tags for use in the templates. I think the number of these on devot-ee illustrates the same. The actual interface on the channels section is not up to much - it feels stuck in EE1 and not part of EE2 blue arrows for an obvious example. Custom field integration is cumbersome to the level where i attempt to use pixel and tonics playa as a replacement. This is not ideal, as it is not a category addon, but it is still better than the default EE one.

    As i say, i struggle immensely with categories - maybe it is me and my methods but after 25 EE site builds it would suggest to me it is either lacking or just not as friendly as the rest of EE.
    I am pretty sure that if it was not so heavily integrated into EE someone would have replaced it with an addon by now - perhaps Brandon is already considering it!

  • #13 / Sep 01, 2011 6:21pm

    Lisa Wess

    20502 posts

    Thank you for the feedback nevsie!  Some of that correlates with what I’ve read/experienced, some doesn’t.  I know there is a lot of desire out there for more flexibility, say, with handling hierarchy output from categories.  Stuff like that.

    I am going to distill your post down and get it in front of the dev team for review, so that when we do come to categories, that feedback and need is right there.

    Thank you again for taking the time towrite that all up!

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

ExpressionEngine News!

#eecms, #events, #releases