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.

Identifying categories of a calendar entry

February 08, 2011 12:55pm

Subscribe [5]
  • #1 / Feb 08, 2011 12:55pm

    Mitch Cohen

    12 posts

    EE2 question.  How do I identify the categories of a calendar entry (or potentially any entry)?

    Specifically, I’m displaying a monthly calendar, and I want to both limit my display of entries to certain categories as well as class entries by category.

    At this point I have this mess:

    {if entries}
            <td class='{switch}' align='center' width="14%" >
                <a href="http://{day_path=/calendar/calendar_detail}">{day_number}</a>
                {entries}
                        {exp:channel:categories channel="Calendar" category_group="1" show="1|13|12|9|4|24" style="linear"}
                            <div class="cal_{category_id}"><a href="http://{title_permalink=/calendar/calendar_detail}">{title}</a></div>
                        {/exp:channel:categories} 
                {/entries}
            </td>
    {/if}

    Which does in fact limit the entries by category and class them, but 1) this seems like an awful lot of looping, and 2) this repeats each entry multiple times.  I’m sure there’s a better way…

    Thanks!

  • #2 / Feb 08, 2011 5:00pm

    Ingmar

    29245 posts

    How do I identify the categories of a calendar entry (or potentially any entry)?

    For regular entries you have the {categories} tag.

  • #3 / Feb 08, 2011 5:43pm

    Mitch Cohen

    12 posts

    Will this work for calendar entries?  I modified my code to:

    {if entries}
            <td class='{switch}' align='center' width="14%" >
                <a href="http://{day_path=/newsevents/calendar_detail}">{day_number}</a>
                {entries}
                {categories category_group="1" show="1|13|12|9|4|24"}
                    <div class="cal_{category_id}"><a href="http://{title_permalink=/newsevents/calendar_detail}">{title}</a></div>
                {/categories} 
                {/entries}
            </td>
    {/if}

    EE isn’t parsing {categories} at all; it’s spitting back the EE code, unparsed.

    Thanks.

  • #4 / Feb 09, 2011 8:06am

    Sue Crocker

    26054 posts

    It doesn’t look like you can. NOTE: Solspace has a Calendar add-on, but I don’t know if it does what you want either..

  • #5 / Apr 16, 2011 10:28am

    Dave @ Exp:resso

    465 posts

    Hey I really need this too - did you have any luck finding a solution? Seems a bit of an oversight not being able to find out what category an entry is in…

  • #6 / Apr 17, 2011 12:48pm

    Greg Salt

    3988 posts

    Hi CrescendoNZ,

    Whether or not you use an addon like the one that Sue mentioned please do consider submitting a Feature Request if there is functionality that you feel is missing from EE.

    @Mitch, what did you end up doing for this?

    Cheers

    Greg

  • #7 / Apr 17, 2011 6:18pm

    Dave @ Exp:resso

    465 posts

    Ok looks like its going to take some manual PHP then… Can’t use solspace calendar at this stage without creating even more extra work. Have given up submitting feature requests as they all seem to get ignored, or only implemented a year later. Thanks though

  • #8 / Apr 17, 2011 11:38pm

    Lisa Wess

    20502 posts

    A custom query may be the best way to grab this information, or a plugin.  In any case, rather than close this I’m going to shift it down to the CodeShare Corner in case others have tackled this and have recommendations.

    We do read the feature requests and those do impact the software; although they may take some time to be included.  I would encourage you to go ahead and post one if you’d like to see this in the future.

    Thank you.

  • #9 / Apr 18, 2011 3:49am

    Dave @ Exp:resso

    465 posts

    Yep I kinda hacked it together with

    {exp:query sql="SELECT cat_id FROM exp_category_posts WHERE entry_id = '{entry_id}' "}

    These days its quicker to make a module ourselves than worry about feature requests - EE is going to need to address the development pace at some stage or it will inevitably be outpaced by open source alternatives. I’d say thats equally if not more important than dealing with the support situation - anyway thats another story!

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

ExpressionEngine News!

#eecms, #events, #releases