[Beginner] Blocks and HTML structure question
PermalinkI'm thinking that each .item would be a block and then trying to find a way to have a counter or something so I could place the opening and closing .row divs based on how many items are being displayed. Is this possible? Or should each row be a block instead of each item?
I know that I could probably edit the HTML to remove the .row divs, but humor me because I'm interested in the answers to this question with the current HTML in place.
Thank you!
<div class="row"> <div class="item"><!-- data --></div> <div class="item"><!-- data --></div> <div class="item"><!-- data --></div> </div> <div class="row"> <div class="item"><!-- data --></div> <div class="item"><!-- data --></div> <div class="item"><!-- data --></div> </div> <div class="row"> <div class="item"><!-- data --></div> <div class="item"><!-- data --></div> <div class="item"><!-- data --></div> </div>
//in your block's view.php file... <div class="row"> <div class="item"><?php echo $field1; ?></div> <div class="item"><?php echo $field2; ?></div> <div class="item"><?php echo $field3; ?></div> </div> <div class="row"> <div class="item"><?php echo $field4; ?></div> <div class="item"><?php echo $field5; ?></div> <div class="item"><?php echo $field6; ?></div> </div> <div class="row"> <div class="item"><?php echo $field7; ?></div> <div class="item"><?php echo $field8; ?></div> <div class="item"><?php echo $field9; ?></div>
Or you could make a block for each "row" and have the user add the block multiple times as needed to the area:
Neither of those is perfect though. Ideally what you want are "repeating items", which can be achieved very easily using the paid "Designer Content Pro" addon:
http://www.concrete5.org/marketplace/addons/designer-content-pro...
(but note that I haven't updated that for 5.7 yet, so for now it only works on 5.6).
-Jordan
I may have to check out the Designer Content Pro add-on. The CMS that I used for 4.5 years allowed me to do a foreach and iterate through each item which allowed me to control the wrapper HTML like the .row divs in my example.
To your other comment about C5 in Minneapolis: I have seen some fellow Minneapolis comrades talking up C5, I may have to join them for a meetup sometime.
I am not positive, but this might put you on the right track.