[eluser]ibnu drim[/eluser]
I want to access the child data ,,
and I get same array ,,,
this is my views ....,
Code:
<?php
$count = 1; $tCount = 1;
foreach( $posts as $post ):
$primaryImg = $this->models->_unserialize( $post['child']->image_primary );
$secondaryImg = $this->models->_unserialize( $post['child']->image_secondary );
if( $count <= 1 ):
?>
?>
<tr>
<?php
endif;
?>
<td>
<a href="<?php echo base_url(); ?>img.php?act=view&src=<?php echo $primaryImg['file_name']; ?>" rel="group" class="colorbox">title; ?>">
<span class="img"><span><?php echo auto_resize( !$secondaryImg? $primaryImg:$secondaryImg, 100, 0, base_url(), FALSE ) ?></span></span>
<span class="description">
<span class="title"><?php echo $post['child']->title; ?></span>
<span class="text"><?php echo $post['child']->content; ?></span>
</span>
<br class="clear" />
</a>
</td>
<?php
//echo count( array($post) ,COUNT_RECURSIVE);
if( $count >= 2 || $tCount >= count( array($post), COUNT_RECURSIVE ) ):
?>
</tr>
<?php
endif;
?>
<?php
$count = $count >= 2? 1:( $count + 1 );
$tCount++;
endforeach;
?>
</table>
<?php
endif;
?>
</div>
<?php if( isset( $show ) ): ?>
[removed]$(function(){ cl.galleryShow( '<?php echo $show; ?>' ) });[removed]
<?php endif; ?>
this is my controller ..,,,,
Code:
<?php
class Gallery extends Controller {
function Gallery()
{
parent::Controller();
$this->load->helper('image_helper');
}
function index( $slug = FALSE )
{
#show lists or post?
if( empty( $slug ) )
$this->lists();
else
$this->album( $slug );
}
function lists()
{
$this->load->model('model_posts');
$this->load->model('model_gallery');
$posts = $this->model_gallery->getPosts();
// $posts = $this->model_gallery->getChild();
$data = array(
'contentPage' => 'gallerys',
'breadcrumb' => $this->model_posts->createBreadCrumb(),
'advTop' => FALSE,
'posts' => $posts,
);
$this->load->view('index', $data);
}
function child()
{
$this->load->model('model_posts');
$this->load->model('model_gallery');
$posts = $this->model_gallery->getPosts();
$data = array(
'contentPage' => 'gallerychild',
'breadcrumb' => $this->model_posts->createBreadCrumb(),
'advTop' => FALSE,
'posts' => $posts,
'data' => $this->model_gallery->getByID( $this->input->get('id') )
);
$this->load->view('index', $data);
}
function album( $slug = FALSE )
{
if( empty( $slug ) )
show_404();
$this->load->model('model_posts');
$this->load->model('model_gallery');
$posts = $this->model_gallery->getPost();
$post = $this->model_gallery->getChild( $slug );
$data = array(
'contentPage' => 'gallery',
'breadcrumb' => $this->model_posts->createBreadCrumb(),
'advTop' => FALSE,
'posts' => $post
);
//if( $post )
//$data['show'] = $posts->title ;
$this->load->view('index', $data);
}
}
this is my models ..,,,,
function getChild( $slug = FALSE )
{
$this->db->where('status', 1)
->where('parent', 0)
->where('slug', $slug)
->from('gallery');
$query = $this->db->get();
$posts = array();
foreach( $query->result() as $result )
{
$galler = array();
#has Child?
$child = $this->pagesHierarchy( $result->ID );
if( $child )
{
foreach( $child->result() as $c )
$galler['child'][] = $c;
$galler['parent'] = $result;
$posts[] = $galler;
}
}
return $posts;
}
function pagesHierarchy( $idParent = FALSE )
{
if( !$idParent || empty( $idParent ) )
return FALSE;
$this->db->where('parent', $idParent)
->from('gallery')
->order_by('ID', 'ASC');
$RES = $this->db->get();
return $RES->num_rows() <= 0? FALSE:$RES;
}
Code:
and I get same error in that php ,,
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: libraries/Loader.php(673) : eval()'d code
Line Number: 10
help me , anyone master ...