Welcome Guest, Not a member yet? Register   Sign In
I have problem
#6

[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 ):
?&gt;                    
?&gt;                    
                       <tr>
&lt;?php
            endif;
?&gt;
                            <td>
                                <a href="&lt;?php echo base_url(); ?&gt;img.php?act=view&amp;src=&lt;?php echo $primaryImg['file_name']; ?&gt;" rel="group" class="colorbox">title; ?&gt;">
                                    <span class="img"><span>&lt;?php echo auto_resize( !$secondaryImg? $primaryImg:$secondaryImg, 100, 0, base_url(), FALSE ) ?&gt;</span></span>
                                    <span class="description">
                                        <span class="title">&lt;?php echo $post['child']->title; ?&gt;</span>
                                        <span class="text">&lt;?php echo $post['child']->content; ?&gt;</span>
                                    </span>
                                    <br class="clear" />
                                </a>
                            </td>
&lt;?php
        //echo count( array($post) ,COUNT_RECURSIVE);
            if( $count >= 2 || $tCount >= count( array($post), COUNT_RECURSIVE ) ):
?&gt;                        
                        </tr>                        
&lt;?php
            endif;
?&gt;
&lt;?php
            $count = $count >= 2? 1:( $count + 1 );
            
          $tCount++;            
        endforeach;
?&gt;
                   </table>
&lt;?php
    endif;
?&gt;
                </div>
&lt;?php if( isset( $show ) ): ?&gt;
                [removed]$(function(){ cl.galleryShow( '&lt;?php echo $show; ?&gt;' ) });[removed]
&lt;?php endif; ?&gt;

this is my controller ..,,,,
Code:
&lt;?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 ...


Messages In This Thread
I have problem - by El Forum - 07-18-2011, 05:33 AM
I have problem - by El Forum - 07-18-2011, 09:33 AM
I have problem - by El Forum - 07-18-2011, 09:49 AM
I have problem - by El Forum - 07-19-2011, 01:53 AM
I have problem - by El Forum - 07-19-2011, 01:24 PM
I have problem - by El Forum - 07-19-2011, 08:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB