0

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 . Can someone help me? I should also mention the php is being rendered on input. Thanks!

4

1 回答 1

0

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).

于 2013-03-29T20:00:06.913 回答