sisterlarao Posted June 1, 2015 Share Posted June 1, 2015 Hey, I am a processwire newbie. I found the module "repeater fields". Everything is working finde. My titles are showing - but not the images. My code: I already tried different variables, but the images are not showing (attachement image). div class="container-fluid"> <div class="row"> <? foreach ($page->columns as $col):?> <div class="col-sm-3 img-responsive"> <a href="#"> <img src="<?php echo $col->images; ?>" /> </a> <div class="test"><a href="#"><?=$col->title; ?> </a></div> </div> <? endforeach; ?> </div> </div> Anyone an idea? Thank you! Link to comment Share on other sites More sharing options...
bernhard Posted June 1, 2015 Share Posted June 1, 2015 <a href="#"> <img src="<?php echo $col->images; ?>" /> </a> should be something like <a href="#"> <img src="<?php echo $col->image->url; ?>" /> </a> attention: you can set up image fields to have ONE ore MULTIPLE images in it. if you set the max number to ONE, then the example above will work. if you set it to multiple files, you would need something like this: foreach($col->images as $img) { echo '<a href="#"> <img src="' . $img->url . '" /> </a>'; } welcome to processwire and the forum happy processwiring! 1 Link to comment Share on other sites More sharing options...
mr-fan Posted June 1, 2015 Share Posted June 1, 2015 (edited) Welcome to processwire! No problem you should read about the difference that your title field is a "field" and your image field is a "array" of images/files... so try with: div class="container-fluid"> <div class="row"> <? foreach ($page->columns as $col):?> <div class="col-sm-3 img-responsive"> // get the very first image from images list since image field is accepting multiple images (unless you change the value of `Maximum files allowed` under Fields > images > Details tab > Maximum files allowed). <a href="#"> <img src="<?php echo $col->images->first(); ?>" /> </a> <div class="test"><a href="#"><?=$col->title; ?> </a></div> </div> <? endforeach; ?> </div> </div> edit: BernhardB beat me.... Edited June 1, 2015 by mr-fan 1 Link to comment Share on other sites More sharing options...
sisterlarao Posted June 1, 2015 Author Share Posted June 1, 2015 Thanks for your fast answers. I already found these codes you posted, but they are not working, too. Text works, but no images. Link to comment Share on other sites More sharing options...
bernhard Posted June 1, 2015 Share Posted June 1, 2015 if you are new i would suggest to keep everything as simple as possible: so start with a single image-field and a SINGLE image to get familiar with it. note that "images" and "image" in the code above assumes that your field's name is set to those values. what errors do you get? Link to comment Share on other sites More sharing options...
mr-fan Posted June 1, 2015 Share Posted June 1, 2015 if no errors shown please check for debug mode in config.php under /site/config.php $config->debug = true; Link to comment Share on other sites More sharing options...
sisterlarao Posted June 1, 2015 Author Share Posted June 1, 2015 http://testdrive.nmore.de/process/autogutsche/ no error. I switch into true and no error appears. There is just no image. Link to comment Share on other sites More sharing options...
mr-fan Posted June 1, 2015 Share Posted June 1, 2015 can you post a image with the field settings, name, of the images field - may one of the backend entries of the repeater, too? Link to comment Share on other sites More sharing options...
sisterlarao Posted June 1, 2015 Author Share Posted June 1, 2015 Link to comment Share on other sites More sharing options...
mr-fan Posted June 1, 2015 Share Posted June 1, 2015 ok found the missing thing...deeper look in your html shows: <a href="#"> <img src="unfallservice.png"> </a> so the imagename is there....not the path/url...so it was wrong example from me...since i load the image always in a var like: //get the first image from the array of the repeater field $myimage = $col->images->first(); and then use it like: //use the $myimage var to call all needed things like url, name, description... <a href="#"> <img src="<?php echo $myimage->url; ?>" alt="<?php echo $myimage->description; ?>" /> </a> you can set the size, too with this API calls have a good read here: https://processwire.com/api/fieldtypes/images/ there is my example, too for a fast look you could quick change: <a href="#"> <img src="<?php echo $col->images->first(); ?>" /> </a> //to <a href="#"> <img src="<?php echo $col->images->first()->url; ?>" /> </a> best regards mr-fan 3 Link to comment Share on other sites More sharing options...
sisterlarao Posted June 1, 2015 Author Share Posted June 1, 2015 Jippi thank you! This is working. Great Support! Link to comment Share on other sites More sharing options...
mr-fan Posted June 1, 2015 Share Posted June 1, 2015 i see it works now...glad you get it! PW is great - the API is easy and flexible - if you dig deeper as easier is will be also recommend the google forum search (the forum search isn't that good) : https://processwire.com/talk/topic/6196-easy-search-on-pw-forums-with-google/?p=60632 1 Link to comment Share on other sites More sharing options...
nanda Posted June 9, 2015 Share Posted June 9, 2015 i have children on the page,and on that children1 i have another children2 i confused to showing children2 using foreach . what should i do? 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