EllisLab text mark
Advanced Search
     
Comment script at bottom of page
Posted: 02 July 2007 06:50 PM   [ Ignore ]
Joined: 2007-07-02
4 posts

Hi everybody!

I just started using CI a day ago and changed the code of small existing scripts to get an idea of the workings of CI. The website I have has a couple of controllers that display different things into an ‘end view’. I’m not totally happy with the structure of the controllers/views…. I would like to know what the best way is to put a comment script at the bottom of all the controllers that can be viewed on my page. It will consist of a title/message box, a submit button and a list of previous comments to that specific controller.

Should I put the code into a PLUGIN and call it from the ‘end view’? Or is there a much cleaner, better way for this?


PS.
Does somebody know a website that is built on CI and which has some controllers, helpers, which generates a front for which the main controller only generates the content AND! has a downloadable source? :) The best way I learn structures is to see it right in front of me. The CI user guide is very nice, but it mainly covers very basic information.

 
Posted: 02 July 2007 09:28 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2007-06-13
70 posts

Okay from what I am understanding and correct me if I am wrong, you are basically wanting to add a footer with functionality?

If this is indeed the case this is how I did it.

/* on the views added this respectively */
<?php include HEADER?>
<?php 
include FOOTER?>

/* controller */
class Indexhome extends Controller {
   
function Indexhome()
   
{
      parent
::Controller();
      
define('HEADER'APPPATH 'views/header.php');
      
define('FOOTER'APPPATH 'views/footer.php');
   
}
      
function index()
      
{    
         $data[
'title''Example';
         
$this->load->view('indexhome'$data);
      
}

This may or not be the best way but I myself am fairly new to CI also look at http://ellislab.com/forums/viewthread/55574/

 
Posted: 03 July 2007 07:11 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2007-07-02
4 posts

Yes, you could see it as a footer. The thing is that I just don’t want to have to put a lot of common code for calling the comments into all the different controllers, but it should be fixed in a common output. If I put a comment ‘view’ at the end of all the controllers, they should all have some extra lines to also get the data that the comment ‘view’ needs from the database.

 
Posted: 03 July 2007 07:24 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2006-07-10
485 posts

Do a search for ‘View library coolfactor’. You should see one thread with several pages of posts. It allows you to use PHP as a template system without using a parsing engine or proprietary templating language.

You might also do a search for ‘views within views’.

 
Posted: 03 July 2007 10:15 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2007-07-02
4 posts

Thank you very much for the reply. I have read about coolfactor’s script, but I thought this was such a basic structure that it would be possible to generate it by using the CI base only. I’ll try out his script.