QUICK QUESTION!
8 posts by 2 authors in: Forums > CMS Builder
Last Post: August 29, 2009 (RSS)
I cannot use the "record Num" code because when you delete a listing, it's record number deletes with it.
So the sort order will determine what comes first... but the number 1 will always remain next to the first listing.. and so on. [crazy]
Creative Director
JAM Graphics
Re: [jtedescojam] QUICK QUESTION!
By Chris - August 29, 2009
Find the foreach statement in your page that is looping over your records:
<?php foreach ($productRecords as $record): ?>
...
<?php endforeach; ?>
Add the lines in bold around the foreach statement and you'll have your counter!
<?php $counter = 0; ?>
<?php foreach ($productRecords as $record): ?>
<?php $counter++; ?>
<?php echo $counter; ?>
...
<?php endforeach; ?>
Hope this helps! Please let us know if you have any questions or comments.
Chris
Re: [chris] QUICK QUESTION!
So how would I put in the code so I have a list of numbers 1 through 10 using the counter you gave me.. along side another list of numbers 1 through 10, using the same code?
Creative Director
JAM Graphics
Re: [jtedescojam] QUICK QUESTION!
By Chris - August 29, 2009
Did you forget to add the <?php $counter = 0; ?> code before the second time you start counting?
If that's not the problem, please attach the PHP source code of the page your working here and we'll have a look.
Chris
Re: [chris] QUICK QUESTION!
By jtedescojam - August 29, 2009 - edited: August 29, 2009
Keep in mind also... the reason for this counter is specifically in order to call up the javascript collapse effect in the head. seen here: http://www.recamerica.com/REC/featuredListings2.php
<?php $counter = 0; ?>
<?php foreach ($featured_listingsRecords as $record): ?>
<div id="listing" class="clienteditor">
<div id="listing-town" ><a href="javascript:animatedcollapse.toggle('listing-body-<?php $counter++; ?><?php echo $counter; ?>')">
<div id="city-state"><?php echo $record['title'] ?></div>
<div id="price"><?php echo $record['price'] ?></div>
</a></div>
<div id="listing-body-<?php $counter = 0; ?><?php $counter++; ?><?php echo $counter; ?>">
<?php foreach ($record['photo'] as $upload): ?>
<div id="listing-photo"><a href="<?php echo $record['website_link'] ?>" target="_blank"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt='' border="0"/><br/>
<?php endforeach ?></a></div>
</div>
</div>
<?php endforeach; ?>
And the result must look like this:
<a href="javascript:animatedcollapse.toggle('listing-body-1')">
<div id="listing-body-1"></div>
<a href="javascript:animatedcollapse.toggle('listing-body-2')">
<div id="listing-body-2"></div>
etc...
Also.. view this URL to see how this should work in the end.. except this one works because I RIGGED the numbers manually.. (no good because I need to be able to mix up the listings often using the sort order). http://www.recamerica.com/REC/featuredListings.php
Creative Director
JAM Graphics
Re: [jtedescojam] QUICK QUESTION!
By Chris - August 29, 2009
Ah-ha! You want one counter, but you want to display its value twice?
If I understand what you want correctly, you'll need to replace this line:
<div id="listing-body-<?php $counter = 0; ?><?php $counter++; ?><?php echo $counter; ?>">
with this:
<div id="listing-body-<?php echo $counter; ?>">
Please let us know if this solves your problem! :)
Chris
Re: [chris] QUICK QUESTION!
http://www.realtyexecutivesnj.com
Creative Director
JAM Graphics
Re: [jtedescojam] QUICK QUESTION!
By Chris - August 29, 2009
Nicely done! :D
Chris