Recent Topics

1 Oct 09, 2005 06:03    

I'm wondering if it's possible to programmatically number each post on a page, by adding an id="#" to the post div itself... So, for example, the output would look like this:



blah blah blah

<div id="post1" class="bPost" lang="en-US">post content</div>
<div id="post2" class="bPost" lang="en-US">post content</div>
<div id="post3" class="bPost" lang="en-US">post content</div>

blah blah blah

Anyone have any ideas?

jj.

2 Oct 11, 2005 01:32

Sure, you should be able to do this. Just insert a little counter variable that you can output in the middle of your div tag, then bump up one right before the loop starts over:


<?php //initialize the counter
$counter = 1;

while ( $Item = $MainLinst->get_item() ) { // the post loop begins
?>
<div id="post<?php echo $counter ?>" class="bPost" lang="en-US">
<?php
// all the code for displaying the post goes here (including the closing div tag)

++$counter // move the counter up one for the next time through
} // the post loop ends
?>


Form is loading...