Help with planning a CI project

#41
[eluser]theprodigy[/eluser]
not a problem. I do what I can to help.

If you return too soon, I may not be here, as I am heading off to the land of pillows and blankets.

Good luck with your project

#42
[eluser]invision[/eluser]
Hehe, I'm heading to the land of goalposts and penalties. Football Big Grin


Thanks again

#43
[eluser]invision[/eluser]
Hi theprodigy,

Me again Smile

I just have a quick question.
In my News page, I'm wanting to list News entries taken from the news sql table. Which then links to their respective news items.

How would you suggest I do this?

Is there a simple way to visit: www.site.com/index.php/page/news and it would list my news items?
Each with a link to view more of the news item?

I mean, would my news function in my MPages Model have to retrieve data from a function in my MNews Model?
I think it's just a bit of work to my pages/news controller.

Sorry, if it's a bit confusing.


Thanks again for any help you can give.

#44
[eluser]invision[/eluser]
I have a follow-up query if this is ok.

In my /aboutus/ section I have a page called Profile.
So the URL is /aboutus/profile/.

I'd like to display results from a specfic MySQL table on this page.

How could I single out the Profile page so only it shows the MySQL results?

Here is my current Controller:

Code:
class Page extends Controller {
  function Page(){
    parent::Controller();
    session_start();
  }

  function index(){
    $data['page_data'] = $this->MPages->getPageBySlug('home');
    $data['cats'] = $this->MPages->getPages();
    $data['title'] = $data['page_data']['title'];
    $data['main'] = 'public_home';
    $this->load->vars($data);
    $this->load->view('template');  
  }
  
  function aboutus($page="profile") {  
    //die($page)
    $this->pages($page);
  }
  
  function services($page="services") {
    $this->pages($page);
  }
  
  function pages($slug){
    $data['page_data'] = $this->MPages->getPageBySlug($slug);
    $data['page_data'] or redirect('page/aboutus');
    
    $data['title'] = $data['page_data']['title'];
    $data['id'] = $data['page_data']['id'];
    $data['body'] = $data['page_data']['body'];
    $data['main'] = 'public_page';
    $this->load->vars($data);
    $this->load->view('template');  
  }
  
}


Many thanks for any help you can give.

#45
[eluser]Ivar89[/eluser]
nvm this, srry

#46
[eluser]invision[/eluser]
That's ok.

The main problem is that it checks if it's aboutus or has that slug. And if so, it uses the pages function.
I just want it to do something a little different to the pages function for this particular page.

#47
[eluser]Ivar89[/eluser]
if this:
Code:
$data['page_data'] = $this->MPages->getPageBySlug($slug);
is how you get your data from a database then you can simply do this in your view:
Code:
<?php foreach($page_data as $data): ?>
<table>
<tr style="background-color: lightgrey;">
<td>ID</td>
<td>Name</td>
<td>Page Url</td>
<td>Published date</td>
<td />
<td />
<td />
</tr>
&lt;?php foreach($page_data as $data): ?&gt;
<tr>
<td>&lt;?php echo $data->ID_Page ?&gt;</td>
<td>&lt;?php echo $data->strTitle ?&gt;</td>
<td>&lt;?php echo $data->strPageUrl ?&gt;</td>
<td>&lt;?php echo $data->datPublicationDate></td>
<td>&lt;?php echo anchor('data/edit/'.$page->ID_Page, 'Edit');?&gt;</td>                                
<td>&lt;?php echo anchor('data/delete/'.$page->ID_Page, 'Delete');?&gt;</td>
<td>&lt;?php echo anchor('data/Images/'.$page->ID_Page, 'Add/Editimages');?&gt;</td>
</tr>
&lt;?php endforeach ?&gt;
</table>
this is a part of my own code since I am almost doing the same thing as you atm. but I hop you get the idea.
this is the list, now what I did was make a edit page and just load a ID in it to see more of the page/news item.
also;
Code:
$this->load->vars($data);
    $this->load->view('template');
can be shortened by:
Code:
$this->load->view('template', $data);

hope I helped ^^

#48
[eluser]invision[/eluser]
Thanks for the reply.

I'm using the following code:

Code:
&lt;?php
echo '<h2>'.$page_data['title'].'</h2>';
echo auto_typography($page_data['body']);
?&gt;
&lt;?php

?&gt;
&lt;?php

  if ($id == 4) {
      
      $this->load->model('MPdfs');
        $data['posts'] = $this->MPdfs->getAllPdfs();
  
      if (count($posts)){
        echo "<table border='1' cellspacing='0' cellpadding='3' width='700'>\n";
        echo "<tr valign='top'>\n";
        echo "<th>ID</th>\n<th>Title</th><th>Preview</th><th>Status</th><th>Actions</th>\n";
        echo "</tr>\n";
        foreach ($posts as $key => $list){
            echo "<tr valign='top'>\n";
            echo "<td>".$list['id']."</td>\n";
            echo "<td>".$list['title']."&nbsp;</td>\n";
            echo "<td><a href='/download/pdf/".$list['>Download</a></td>\n";
            echo "<td align='center'>".$list['status']."</td>\n";
            echo "<td align='center' nowrap>";
            echo anchor('admin/pdfs/edit/'.$list['id'],'edit');
            echo " | ";
            echo anchor('admin/pdfs/delete/'.$list['id'],'delete');
            echo "</td>\n";
            echo "</tr>\n";
        }
        echo "</table>";
    }
    
    
  }

?&gt;

But keep getting this error:

Code:
A PHP Error was encountered
Severity: Notice

Message: Undefined variable: posts

Filename: views/public_page.php

Line Number: 15

Is this because $posts isn't storing any data?

#49
[eluser]invision[/eluser]
Yep.
Seems to be the case that $posts isn't getting the data.
I've tried just making $posts['id'] = '1'; and it displays a table.

I'm assuming this is where the problem lies:
Code:
$data['posts'] = $this->MPdfs->getAllPdfs();

#50
[eluser]Ivar89[/eluser]
Not necessarily
you can check if it is empty or not with the adding this code to your controller:
Code:
echo var_dump($posts);
exit();
helped me allot!
Mostly (atleast with me) when I see error about undefined var in my view is because it simply does not know what it is or does or store so either a typo or not correctly defined in your controller.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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