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.

Unexpected results with {exp:channel:categories} and PHP (Output)

September 12, 2012 12:14pm

Subscribe [1]
  • #1 / Sep 12, 2012 12:14pm

    ChiefAlchemist

    913 posts

    I posted ealier, about 30 minutes ago. While I’m waiting to see what that brings I decided to try a different approach.

    <?php $cnt = 1; ?>
    {exp:channel:categories channel='events' category_group='3'  style='linear'}
    <li> -----------------------</li>
    <li> $cnt = <?php echo $cnt; ?></li>
    <li> parent_id = {parent_id}</li>
    <li> embed:parent = {embed:parent}</li>
    
    {if parent_id == embed:parent}
    
    <?php if ($cnt == 1) { ?>
    <li class="tour-event"><a href="http://{path=/{segment_1}/{category_url_title}}"><?php echo '= '.$cnt; ?> - {category_name}</a></li>
    <?php $cnt = $cnt + 2;} else { ?>
    
    <li class="tour-event"> :: <a href="http://{path=/{segment_1}/{category_url_title}}"><?php echo '= '.$cnt; ?> - {category_name}</a></li>
    
    <?php } ?>
    {/if}
    {/exp:channel:categories}

    Since I can’t get the backspace to work (as desired / expected), I figured I could accomplish similar with a flag/toggle. Basically, if it’s the first child don’t prefix that ’ :: ’ separator. For all other children prefix ’ :: ‘.

    But it’s not working as expected (or maybe it’s a parse order issue). Here’s a snippet of my output:

    ———————————
    $cnt = 1
    parent_id = 0
    embed:parent = 17
    ———————————-
    $cnt = 3
    parent_id = 17
    embed:parent = 17
    :: = 3 - Child 1 (July 2013)
    ———————————-
    $cnt = 3
    parent_id = 17
    embed:parent = 17
    :: = 3 - Child 2 (May 2013)
    ———————————-

    The first “row” is the parent. It passes over that because parent_id != embed:parent. Then somehow my flag $cnt changes value, as if the first child was already displayed. But the flag isn’t supposed to change until after that.

    I’m super confused.

    Thanks in advance
    Mark

  • #2 / Sep 14, 2012 7:58am

    ChiefAlchemist

    913 posts

    Nuttin’? Not even from EL? :(

  • #3 / Sep 14, 2012 2:58pm

    Dan Decker

    7338 posts

    Hey ChiefAlchemist,

    I do apologize for your wait, just as the Support Policy says:

    We aim to answer all support requests within 2 business days.

    I followed up with your other thread. Let’s keep our focus there for now.

    I’m going to close this one down, so we don’t get lost.

    Thanks!!

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

ExpressionEngine News!

#eecms, #events, #releases