Jump to content

Search the Community

Showing results for tags 'foreach loop'.

  • 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 2 results

  1. I was previously using individual fields to capture and output multiple cards onto my web page but after recently learning about repeaters would prefer to use this field type, as it will be a lot more user friendly for end users to create new cards. I tried to modify my code to grab the fields from the new Repeater field(s) but am getting this error message on the page: Here is the code I'm currently trying to use for the cards: <?php // https://processwire.com/api/arrays/ // check if the array of images has items foreach($page->tall_card as $card) { $count = 0; $count++; $options = array( 'quality' => 70 ); $image = $card->image; $img = $card->image->size(550, 400, $options); $cardHeading = $card->title; $cardBody = $card->plain_paragraph; $raised = $card->raised_amount; $goal = $card->goal_amount; $link = $card->link; if ($raised == 0 ) : $percent = 0; else: $percent = $raised_amount / $goal_amount * 100; endif; if ($percent <= 5) : $percent = 0; endif; ?> <span id="card<?php echo $count?>" class="card"> <img class="cardThumb" src="<?php echo $img->url; ?>" alt="<?php echo $image->description; ?> Thumbnail" /> <div class="cardBody"> <div class="cardText"> <h2><?php echo $cardHeading; ?></h2> <?php echo $cardBody; ?> </div> <div class="progressBarSection"> <progress class="progressBar" id="progressbar<?php echo $count; ?>" value="<?php echo $percent; ?>" max="100"></progress> <span class="raisedAmount"> $<?php echo $raised; ?> usd </span> <span class="goalAmount"> $<?php echo $goal; ?> usd </span> </div> <div class="primaryBtn"> <a href="https://www.paypal.com/donate?hosted_button_id= <?php echo $link; ?> &source=url"> <button> <i class="fas fa-donate"></i> Donate </button> </a> </div> </div> </span> <?php } ?> Thanks in advance for any help!
  2. Hi Guys! I have a bit of a puzzle for you. I have been mapping this one out in my brain and on paper all week. I haven't come up with the right solution yet. Here is the project. I am working on a directory site similar to http://demo.processwire.com/ but for another subject. Let's say I am building the skyscraper site but let's say I am doing this for restaurants in cities. I am building a parent page called cities and then a parent page called restaurants. Goal is to display the restaurants according to popularity. Therefore, if I am storing the pages under their appropriate parent. Restaurants are under restaurants and cities are under cities. Visual Page Tree: Cities New York Chicago New Orleans Restaurants Big Toms Burgers McDonalds Dominos Now a restaurant may have 10 locations therefore, I am using a foreach loop inside of the city page to call all restaurants that pertain to this city and sorting by popularity. ? Here is the kicker, how the heck do I document the position the restaurant appears in under the city? Do I save a value in the database? I know I can use a counter to count the loops and assign a value then save that value to the database to the pertaining Restaurant but this relies on page loads and imagine 1000 restaurants all updating at the same time on the database on page load. WOW! No go. How the heck do I save this value without ever having to load a page? ALL IDEAS WELCOME PLEASE! ?
×
×
  • Create New...