dev_panther Posted August 11, 2015 Share Posted August 11, 2015 When I'm using wireArray, both with repeater and image field with more than one image, I have a problem getting the content of the array. For example, I have the following code where info_tabs is a repeater of textarea fields. $texts = $page->info_tabs; foreach ($texts as $tab){ echo "<div>; echo $tab; echo "</div>; } Instead of echoing the text, the page is echoing numbers, it is echoing the numbers 1029-1032. why is that? Link to comment Share on other sites More sharing options...
mr-fan Posted August 11, 2015 Share Posted August 11, 2015 (edited) Since a Repeater item is a kind of page the numbers are the id's of the extries of the repeater... so have a closer look at: https://processwire.com/api/fieldtypes/repeaters/ like in the example you have to call the fields like: foreach ($page->info_tabs as $tab){ echo "<div>"; echo $tab->title; //or if you have a special text field echo $tab->myFieldName; echo "</div>"; } regards mr-fan Edited August 11, 2015 by LostKobrakai Fixed missing quotes 2 Link to comment Share on other sites More sharing options...
dev_panther Posted August 11, 2015 Author Share Posted August 11, 2015 (edited) thanks! can you maybe that also for the case of images array? Because in that case each image doesn't have a field (or does it?) right now i use foreach($images as image){ $imagesrc = "{$image->url}{$image}"; } to get the whole image src, but it seems kind of redundant. Is there a better way? Edited August 11, 2015 by LostKobrakai Fixed another missing quote Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 11, 2015 Share Posted August 11, 2015 The url field should give you the complete relative url to the image. foreach($images as $image){ echo "<img src='$image->url' alt='$image->description'>"; } Link to comment Share on other sites More sharing options...
bernhard Posted August 12, 2015 Share Posted August 12, 2015 hi dev_panther, whenever you have a strange behaviour you can make use of debugging: https://processwire.com/talk/topic/4550-debugging-tips/ 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now