diegonella Posted January 28, 2012 Posted January 28, 2012 Hello I have a list of items loaded, that within the template have an image field and want to get a list of only those with a loaded image. As I can do? thank you very much
Soma Posted January 28, 2012 Posted January 28, 2012 It's hard to understand what exactly you want to do. Can you also try to put some spaces between your words? Thx. You can grab an image using the image field name. If its setting is to allow only a single image file you can do: // single image field echo $pageobject->imagefield->url; echo $pageobject->imagefield->size(100,100)->url; If the image field is set to allow multiple images, you must use a loop to cycle through them, or chose the first, or maybe a random one. // multiple foreach($page->imagesfield as $img){ $thumb = $img->size(100,100)->url; echo "<img src='$thumb' />"; } // or chose first from image array $page->imagesfield->first->url; // or random $page->imagesfield->getRandom(1)->url; // grab pages using a special template and output a list of their images. $pa = $pages->find("template=yourtemplate"); echo "<ul>"; foreach($pa as $p){ $thumb = $p->imagefield->width(100)->url; echo "<li><img src='$thumb'/></li>"; } echo "</ul>"; Does that help you? If not can you provide better and more information what you want to do?
WillyC Posted January 28, 2012 Posted January 28, 2012 wanted something.like this do u? $pages->find("images.count>0")
Soma Posted January 28, 2012 Posted January 28, 2012 wanted something.like this do u? $pages->find("images.count>0") Might be what he looking for after reading again. That will look for pages with the "images" field populated.
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