Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeigniter -> Edit Page
    primarykey
    data
    text
    <p>I am getting the following error when I try and access:</p> <p><strong>domain.co.nz/admin/editpage/home/</strong></p> <p>I get the following error:</p> <pre><code>PHP Fatal error: Call to a member function getCMSPage() on a non-object in controllers/home.php on line 22 </code></pre> <p>The issue with this is that I cannot understand why it is being passed back into the main <strong>“home” controller</strong> - which is the main controller.</p> <p>All of my models are loaded by default - <a href="http://cl.ly/2U1F3a2B0s2K0i3k3g13" rel="nofollow">http://cl.ly/2U1F3a2B0s2K0i3k3g13</a></p> <p><strong>Ideal Situation</strong></p> <p>What I am trying to do with this is load the content into a text area on for editing and when submit is clicked I would like it to go back to the same page with a message saying content updated.</p> <p><strong>Admin Template</strong></p> <pre><code>&lt;li&gt;&lt;?php echo anchor('#','Edit Pages');?&gt; &lt;?php if(is_array($cms_pages)): ?&gt; &lt;ul&gt; &lt;?php foreach($cms_pages as $page): ?&gt; &lt;li&gt;&lt;a &gt;permalink?&gt;"&gt;&lt;?=$page-&gt;name?&gt;&lt;/a&gt;&lt;/li&gt; &lt;?php endforeach; ?&gt; &lt;/ul&gt; &lt;?php endif; ?&gt; &lt;/li&gt; </code></pre> <p><strong>Page Model</strong></p> <pre><code>function updatePage($data){ $data = array('content' =&gt; $content); $this -&gt;db-&gt;where('id',$id); $this-&gt;db-&gt;update('pages',$data); } </code></pre> <p><strong>View:</strong></p> <pre><code>&lt;?php //Setting form attributes $formpageEdit = array('id' =&gt; 'pageEdit', 'name' =&gt; 'pageEdit'); $formInputTitle = array('id' =&gt; 'title', 'name' =&gt; 'title'); $formTextareaContent = array('id' =&gt; 'content', 'name' =&gt; 'content'); ?&gt; &lt;section id = "validation"&gt;&lt;?php echo validation_errors();?&gt;&lt;/section&gt; &lt;h4&gt;&lt;?= $title ?&gt; &lt;/h4&gt; &lt;?php echo form_open('admin/editpage/'.$page-&gt;permalink, $formpageEdit); echo form_fieldset(); echo form_label ('Content', 'content'); echo form_textarea("content", $page['content']); echo form_submit('submit','Submit'); echo form_fieldset_close(); echo form_close(); ?&gt; </code></pre> <p><strong>Controller:</strong></p> <pre><code>function index(){ if($this-&gt;session-&gt;userdata('logged_in')){ }else{ redirect('admin/home'); } $page = $this-&gt;navigation_model-&gt;getCMSPage($this-&gt;uri-&gt;segment(3)); $data['cms_pages'] = $this-&gt;navigation_model-&gt;getCMSPages(); $data['title'] = $page-&gt;name; $data['content'] = $this-&gt;load-&gt;view('admin/editpage', array('page' =&gt; $page, TRUE)); $this-&gt;load-&gt;view('admintemplate', $data); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload