Jump to content

Get alls images from a field in a other page


justnew77
 Share

Recommended Posts

  Yeah, I saw this doc. But it says nothing about accessing fields in other pages. From this doc I figured out the code above. But it do not work.

Your code seem not to make any sense.

1) Please can you explain to me what the variable $image in the first line should hold. (and what it actually holds)

2) and what do you want to do with a loop in the second line? (and where does $images come from?)

You should go step by step. FIrst you should inspect the first line of code. If this does what you expect / want, go on with the next step.

:-X  And really, you should _read_ the doc kongondo has you pointed to, once or twice more.

  • Like 1
Link to comment
Share on other sites

The two examples you posted won't work because you are using $image in both instances and not $images and then $image. You were also getting the url, rather than just the imageK1 field in your initial line.

What Mats posted will work, but if it makes more sense to you, you can adjust what you wrote to:

$images = $pages->get("/leistungen/dekoration/")->imageK1;
foreach($images as $image) {
    echo $image->url;
}
 

and it should work fine.

What you are doing is assigning all the images in the imageK1 field on the /leistungen/dekoration/ page to the array $images. Then you want to iterate through this, making each item $image and echo it out.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...