9 replies to this topic
#1
Posted 01 May 2012 - 02:58 PM
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
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
#2
Posted 01 May 2012 - 04:56 PM
Welcome to the forum Ben!
You have to iterate over the repeater, and output each field:
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>";
}
#3
Posted 02 May 2012 - 05:58 AM
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:
I'm sure you know it, but typed it wrong in your post.
So things like:
$page->my-repeater-areadoesn't work.
I'm sure you know it, but typed it wrong in your post.
@somartist | modules created | support me, flattr my work flattr.com
#5
Posted 03 May 2012 - 10:04 AM
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/">
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/">
#6
Posted 03 May 2012 - 10:13 AM
If you would show us some code, we would be able to help much easier.
@somartist | modules created | support me, flattr my work flattr.com
#7
Posted 03 May 2012 - 10:17 AM
Just add first() before ->url. I guess you have an array instead of single image.
#8
Posted 03 May 2012 - 10:30 AM
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}' />";
}
}
#9
Posted 03 May 2012 - 10:30 AM
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 "-"))
{
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 "-"))
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users












