CodeIgniter Forums
Comment script at bottom of page - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Comment script at bottom of page (/showthread.php?tid=1877)



Comment script at bottom of page - El Forum - 07-02-2007

[eluser]appelflap[/eluser]
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? Smile 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.


Comment script at bottom of page - El Forum - 07-02-2007

[eluser]Christopher Blankenship[/eluser]
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.
Code:
/* 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/


Comment script at bottom of page - El Forum - 07-03-2007

[eluser]appelflap[/eluser]
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.


Comment script at bottom of page - El Forum - 07-03-2007

[eluser]esra[/eluser]
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'.


Comment script at bottom of page - El Forum - 07-03-2007

[eluser]appelflap[/eluser]
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.