Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/15/2012 in all areas

  1. I've been working on making repeatable fields for ProcessWire for a couple weeks and actually now have it nearly ready. I need to do some more testing before releasing it, but wanted to give you a little preview. (please view the full screen version for better quality) Accessing repeatable fields from the API is super-easy. They are fully searchable/selectable with the API just as easily as with any other fields. So if you wanted to find all pages that had a buildings field with a floors value of 50 or more, you'd do this, for example: $pages->find("buildings.floors>=50"); Lets say you are on the page with a 'buildings' field and you want to print out all the building names and number of floors. It works exactly the same as page references: foreach($page->buildings as $p) { echo "<p>{$p->building_name}</p> has {$p->floors} floors.</p>"; }
    2 points
  2. I agree with Pete. This sounds like you are accessing type 'Pageimages' rather than type 'Pageimage' (singular). Since you are bootstrapping ProcessWire, output formatting is going to be off. One of the side effects of that is that all image fields are treated the same (as arrays of images) rather than single images. Since you are using ProcessWire's data for output in this case, I suggest adding a single call to this before you retrieve any pages from PW: wire('pages')->setOutputFormatting(true); That will turn it on for all anything returned from the $pages API var. Or you can do it for just one page, like your banner $page: $banner->setOutputFormatting(true); Turning outputFormatting on will ensure you get the correct behavior for output. And if your image field is set to hold max 1 image, then it'll also ensure you only get that when accessing $banner->pastilla_imagen.
    1 point
×
×
  • Create New...