bizzzel Posted May 1, 2012 Share Posted May 1, 2012 I added the repeater field to my page. In the php template I added : <?php echo $page->my-repeater-area; ?> When I display the page in a browser - it's showing "1011", not the text and images from what I input in the admin area. What am I missing here? (The sub fields in the for each "my-repeater-area" are: building-description, building-image, and building-text.) Thanks in advanced: Ben Link to comment Share on other sites More sharing options...
diogo Posted May 1, 2012 Share Posted May 1, 2012 Welcome to the forum Ben! You have to iterate over the repeater, and output each field: foreach($page->my_repeater-area as $building) { echo "<p>{$building->building_description}</p>"; echo "<img src='{$building->building_image->url}' alt='{$building->building_image->description}' />"; echo "<p>{$building->building_text}</p>"; } 2 Link to comment Share on other sites More sharing options...
Soma Posted May 2, 2012 Share Posted May 2, 2012 I don't know if you know that variables/namings in php can't contain a dash "-". So also this is true to a field name in PW. So things like: $page->my-repeater-area doesn't work. I'm sure you know it, but typed it wrong in your post. 1 Link to comment Share on other sites More sharing options...
diogo Posted May 2, 2012 Share Posted May 2, 2012 Thanks Soma! Edited the post so it doesn't contain wrong information. I'm glad you are sure I know it, but actually, as I'm really new to PHP (or any programming language, by the way), those things are not that present in my mind... Link to comment Share on other sites More sharing options...
bizzzel Posted May 3, 2012 Author Share Posted May 3, 2012 Thanks for the info!! One issue - Everything works expect the image doesn't display. I checked the source code and the php is trying to show it, but the URL is wrong. Its showing the 1011 again: <img alt="" src="/site/assets/files/1011/"> Should be something like: <img alt="" src="/site/assets/files/1011/my_imageFluffyCat.jpg/"> Link to comment Share on other sites More sharing options...
Soma Posted May 3, 2012 Share Posted May 3, 2012 If you would show us some code, we would be able to help much easier. Link to comment Share on other sites More sharing options...
apeisa Posted May 3, 2012 Share Posted May 3, 2012 Just add first() before ->url. I guess you have an array instead of single image. Link to comment Share on other sites More sharing options...
diogo Posted May 3, 2012 Share Posted May 3, 2012 Or, iterate over all images: foreach($page->my_repeater-area as $building) { echo "<p>{$building->building_description}</p>"; echo "<p>{$building->building_text}</p>"; foreach($building->building_image as $img) { echo "<img src='{$img->url}' alt='{$img->description}' />"; } } 1 Link to comment Share on other sites More sharing options...
bizzzel Posted May 3, 2012 Author Share Posted May 3, 2012 foreach($page->buildingsRepeat as $building) { echo "<p>{$building->buildingInfo}</p>"; echo "<img src='{$building->buildingImage->url}' alt='{$building->buildingImage->description}' />"; echo "<p>{$building->body}</p>"; } Here is the code. Yes looking to display single image. (Sorry I changed the names from original (removed "-")) Link to comment Share on other sites More sharing options...
bizzzel Posted May 3, 2012 Author Share Posted May 3, 2012 Diogo - Your last post worked perfectly!!! Thank You so much - very new to ProcessWire (looking for WordPress replacement) and so far loving me sum ProcessWire. 2 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