Jump to content

Search the Community

Showing results for tags 'loops'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 1 result

  1. $jurisdictionsPageChildren = $pages->get(1011)->children(); // Check whether there are any children before attempting to split them if($jurisdictionsPageChildren > 0) { // Some general vars $rows = 2; $totalCount = count($jurisdictionsPageChildren); $rowCount = $totalCount / $rows; // Creating the seperate list (there has to be an easier way to do this) $firstList = $jurisdictionsPageChildren->slice(0, $rowCount); $secondList = $jurisdictionsPageChildren->slice($rowCount, $totalCount) $mainContent .= "<div class='row jurisdictions-list'>"; // First list of elements $mainContent .= "<div class='columns six alpha'>"; foreach($firstList as $child) { $mainContent .= "<h2><a$class href='{$child->url}' title='{$child->title}'>{$child->title}</a></h2>"; } $mainContent .= "</div>"; // Second list of elements $mainContent .= "<div class='columns six omega'>"; foreach($secondList as $child) { $mainContent .= "<h2><a$class href='{$child->url}' title='{$child->title}'>{$child->title}</a></h2>"; } $mainContent .= "</div>"; $mainContent .= "</div>"; // Close the row class } Okay, here is the deal. I have one list ($jurisdictionsPageChildren) which I want to split into multiple blocks/columns. I would like to adjust this code so I can set the $rows variable to some number. The condition is that the first block (regardless of the number of blocks) has to have a class 'alpha' and that every last block has to have a class 'omega'. I was thinking to put a foreach in a foreach, but somewhere things got messed up. If this was JSP it would do it like this: <c:set var="splittedListHere" value="$(rpfn:splitListFunction(listHere, 2))" /> <c:forEach items="splittedListHere" var="list" varStatus="i"> <div class="block$(i.first ? ' alpha' :'')$(i.last ? ' omega')"> more foreach stuff </div> </c:forEach> Any thoughts to make this prettier for a PHP noob are very welcome.
×
×
  • Create New...