简体   繁体   English

循环中的表达式引擎计数条目

[英]Expression Engine Counting Entries in loop

So I need to count how many entries are being pulled for a certain group. 因此,我需要计算某个组要提取多少条目。 Heres my code dumbed down. 这是我的代码的愚蠢之处。

    <?php $i = 0; ?>
{exp:weblog:entries related_categories_mode="on" custom_fields="on" orderby="view_count_one" sort="desc" limit="4" offset="0" weblog="{my_weblog1}" start_on="<?php echo $current_time; ?>" }

      <table>
        <tr valign="top" style="margin-bottom:10px;">
          <td> {if weblog == "Newsroom"} <a href="{title_permalink="freedom/articles}">{if Image}<img src="{Image}" >{/if}</a>
            {if:elseif weblog == "Health Freedom"} <a href="{title_permalink="freedom/articles}">{if Image}<img src="{Image}" >{/if}</a>
            {/if} <br /></td>
          <td> <h3>{if weblog == "Newsroom"} <a href="{title_permalink="freedom/articles}">{title}</a>
            {if:elseif weblog == "Health Freedom"} <a href="{title_permalink="freedom/articles}">{title}</a>

            {/if} <span class="date">&ndash; {entry_date format='%m/%d/%Y '} </span> </h3>

</td>
        </tr>
<?php $i = $i++; ?>
      <?php $count = '{count}';   ?>
<?php echo $count;?> {/exp:weblog:entries}
<?php echo $count; ?>
<?php echo $i; ?>

So basically during the loop it counts up to 4 with $count, but ontside the weblog I get 1 for $count and 0 for $i . 因此,基本上在循环中,使用$ count最多可以计数到4,但是在网络日志的另一边,我得到$ count的1和$ i的0。 Can someone help me? 有人能帮我吗? I should also mention the php is being rendered on input. 我还应该提到在输入时呈现了php。 Thanks! 谢谢!

Change 更改

<?php $i = $i++; ?>

To

<?php $i++; ?>

The way you have it is setting new $i to old $i and then incrementing old $i (which no longer exists). 您的处理方式是将新$i设置为旧$i ,然后递增旧$i (不再存在)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM