[solved] Parsing array to view problem

#1
[eluser]snortop[/eluser]
I have problem parsing my array into the view.
I get the page and i get a single row data.
But when im parsing into the array, i get a
Quote:Message: Trying to get property of non-object
What am i doing wrong??

My view page, from controllers
Code:
function view()
    {
        $this->load->model('page_model');
        $colpage = $this->page_model->getpagebyname($this->uri->segment(3));
        
        // If no page found show empty page
        if($colpage = false) {
            $this->load->view('page/empty');
        }
        else {
            $data = array(
                'pagedata' => $colpage
            );
            
            $this->load->view('page/view',$data);
        }    
    }

The getpagebyname from model
Code:
function getpagebyname($pagename)
    {
        $this->db->where('head', $pagename);
        
        $query = $this->db->get('page');
        
        return $query->row();
    }

page/view
Code:
<table style="text-align: left; width: 100%;" border="1"
cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <td>
      <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
        <tbody>
          <tr>
            <td style="text-align: left; width: 50%;">
            &lt;?php
                echo $pagedata->head;
            ?&gt;
            </td>
            <td style="width: 50%; text-align: right; vertical-align: top;">
            &lt;?php
            /*
             * Maybe have a image link in here instead
             */
            echo anchor("page/edit/$pagedata->head","Rediger");
            echo " | ";
            echo anchor("page/delete/$pagedata->head", "Delete");
            ?&gt;
            </td>
          </tr>
        </tbody>
      </table>
      </td>
    </tr>
    <tr>
      <td style="width: 100%; text-align: left; vertical-align: top;">
      &lt;?php echo $pagedata->text; ?&gt;
      </td>
    </tr>
    <tr>
      <td style="text-align: center; vertical-align: top;">created data </td>
    </tr>
  </tbody>
</table>

#2
[eluser]sqwk[/eluser]
Try a print_r or var_dump to see what exactly is set in the pagedata object.

#3
[eluser]snortop[/eluser]
well i completly recoded it. using
Code:
$data = array();
$data['pagedata'] = $colpage;

So now it works..

Looking back now... maybe i should have used a ',' in back of the dif array.

Code:
$data = array(
                'pagedata' => $colpage,
            );

#4
[eluser]Kumar Chetan sharma[/eluser]
first of all I will rewrite this
Code:
echo anchor("page/edit/$pagedata->head","Rediger");
similar to this
Code:
echo anchor('page/edit/'.(isset($pagedata->head)?$pagedata->head:''),"Rediger");
secondly, do a var dump and see if you really have the properties set up or not


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.