Jump to content

Recommended Posts

Posted

I am trying to call pages like this

<?php 
				$prishtina = $pages->get("/libri/garazha/prishtina/")->find("sort=-created, limit=0");
				if(count($prishtina->fotoballina)) {
				$image = $prishtina->fotoballina->first(); 
				$thumb = $image->size(50, 50); 	
				echo "
				<table width='100%' border='0' cellspacing='2' cellpadding='1' class='ListTable'>
				<tr>
				<td width=60 height=60 align='center'><a href='{$prishtina->url}'><img id='photo' src='{$thumb->url}' alt='{$thumb->description}' width='{$thumb->width}' height='{$thumb->height}' /></a> {$prishtina->date}</td>
				<td>  KTA:<a href='{$prishtina->url}'>{$prishtina->title}</a><p>  Adresa: {$prishtina->adresa}<p>  Telefoni:{$prishtina->mobile}</td>
				</tr>
				</table>";
				};
				?>

i dont show any error but nothing show in page,  fields are ( fotoballina ,  title , adresa , mobile )

and if i use like this work perfect

<?php 
				$aktivizo = $page->find("template=klienti, sort=-created, peja=1, limit=2");
				foreach ($aktivizo as $portfolio_item) {
				$image = $portfolio_item->fotoballina->first(); 
				$thumb = $image->size(50, 50); 	
				echo "
				<table width='100%' border='0' cellspacing='2' cellpadding='1' class='ListTable'>
				<tr>
				<td width=60 height=60 align='center'><a href='{$portfolio_item->url}'><img id='photo' src='{$thumb->url}' alt='{$thumb->description}' width='{$thumb->width}' height='{$thumb->height}' /></a> {$portfolio_item->date}</td>
				<td> KTA:<a href='{$portfolio_item->url}'>{$portfolio_item->title}</a><p> Adresa: {$portfolio_item->adresa}</td>
				</tr>
				</table>";
				};
				?>
Posted
$prishtina = $pages->get("/libri/garazha/prishtina/")->find("sort=-created, limit=0");

There are a couple problems with this statement above:

1. The code you posted assumes that $prishtina is a single page. And it would be if your statement didn't have the "->find(...)" in it. But the returned value in the statement above is a PageArray (something that can hold multiple pages), not a single Page.

2. The "limit=0" would prevent it from finding anything in the tree of pages below /libri/garazha/prishtina/. Are you sure you didn't mean "limit=1" ?

3. Assuming you changed that "limit=0" to be "limit=1" or something higher, using the "find()" there searches all pages in the structure below /libri/garazha/prishtina/, regardless of whether they are children, grandchildren, etc. I am thinking that you probably want that to be "children()" rather than "find()"? Or better yet, since the code below it assumes it's dealing with a single page, you probably want it to be the "child()" function, which just returns the first matching child Page. So I am thinking this is what you want instead? (below)

$prishtina = $pages->get("/libri/garazha/prishtina/")->child("sort=-created");

Note that there is no need to have a "limit=n" in the selector, because child() just returns 1 page. I'm guessing that if you replaced the snippet above with the one in your code, it would achieve what you were wanting it to (if I've understood it correctly).

Posted

yes i change it to

$prishtina = $pages->get("/libri/garazha/prishtina/")->child("sort=-created");

its work but is calling just one, i like to make for example:

if a go at page /libri/garazha/prishtina/ to show all pages in Prishtina ( Test 1,Test 2,Test 3,etc...) i have just one template with name prishtina,

this is a page list in admin

----------------------------------

Home-

Libri-

------Garazhat

------------------Prishtina

----------------------------- Test 1

----------------------------- Test 2

----------------------------- Test 3

----------------------------- Test 4

----------------------------- Test 5

Posted

In that case, I think you want to change the child() to children() and then loop through the result:

<?php

$children = $pages->get("/libri/garazha/prishtina/")->children("sort=-created, fotoballina>0");

foreach($children as $prishtina) {
    $image = $prishtina->fotoballina->first(); 
    $thumb = $image->size(50, 50); 	
    echo "... your output ...";
}

Note that I added: the "fotoballina>0" (aka "images>0") so that it only returns pages that have at least one image. That way you don't have to check them in the loop.

Posted

A fix and children problem with this code,

<?php 
$aktivizo = $page->children("template=shtiminebanes, foto1banes>0, sort=-date, limit=4");
foreach ($aktivizo as $portfolio_item) {
$image = $portfolio_item->foto1banes->first(); 
        $thumb = $image->size(400, 100); 	
echo "
	<table width='100%' border='0' cellspacing='2' cellpadding='1' class='ListTable'>
	<tr>
	<td width=60 height=60 align='center'><a href='{$portfolio_item->url}'><img id='photo' src='{$thumb->url}' alt='{$thumb->description}' width='{$thumb->width}' height='{$thumb->height}' /></a> {$portfolio_item->date}</td>
	<td> <a href='{$portfolio_item->url}'>{$portfolio_item->title}</a><p></td>
	</tr>
	</table>";
	};
	?>

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
  • Recently Browsing   0 members

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