繁体   English   中英

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

[英]Expression Engine Counting Entries in loop

因此,我需要计算某个组要提取多少条目。 这是我的代码的愚蠢之处。

    <?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; ?>

因此,基本上在循环中,使用$ count最多可以计数到4,但是在网络日志的另一边,我得到$ count的1和$ i的0。 有人能帮我吗? 我还应该提到在输入时呈现了php。 谢谢!

更改

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

<?php $i++; ?>

您的处理方式是将新$i设置为旧$i ,然后递增旧$i (不再存在)。

暂无
暂无

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

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