ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Using CodeIgniter to handle forms?

November 20, 2011 8:40pm

Subscribe [2]
  • #1 / Nov 20, 2011 8:40pm

    jaydisc

    19 posts

    Before I purchased EE, I had some CI experience and I asked if it was easy to just do CodeIgniter work right along side EE and was given a positive impression. I think my expectations were a bit different as I guess I thought I could just create my own controllers and it would just work as expected. It seems there are some solutions that enable me to do that, i.e.:

    http://paramore.is/think/entry/harnessing-the-power-of-codeigniter-in-expressionengine-2.0/

    But I just wanted to get the opinion of some of the more experienced folks here. At first I just want to do a bit more complex form handling than then EE email module seems to offer, but I intend on getting a bit more complex and building full scale applications in and or around the EE part of the public website. I see this question has been asked many times and the common response is to look at the EE developer docs, which I have, but they don’t seem to offer a solution that would seem natural to a former CI developer.

    So, what’s the best to way to integrate the two? Is the above URL considered a good method?

    What about doing some more advanced form handling than the built-in tools? Is the common answer to look for a module/extension/add-on?

    Thank you

  • #2 / Nov 21, 2011 7:34pm

    jaydisc

    19 posts

    OK, so I’m knee deep in Module making, but I just can’t seem to get it to work. I’ve done a very basic test. Here is mod.experience.php:

    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    class Experience {
     
     function __construct()
     {
      $this->EE =& get_instance();
     }
     
     public function test()
     {
      $data['test_message'] = "This is a test";
      $output = $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $data);
      return $output;
     }
    }

    And then here’s my template (very basic for testing purposes):

    {exp:experience:test}
    {test_message}
    {/exp:experience:test}

    However, when I load it, I get:

    A PHP Error was encountered

    Severity: Notice
    Message: Undefined offset: 0
    Filename: libraries/Template.php
    Line Number: 3456

    A PHP Error was encountered

    Severity: Warning
    Message: Cannot modify header information - headers already sent by (output started at /var/www/beta.fireflyeducation.com.au/system/codeigniter/system/core/Exceptions.php:170)
    Filename: core/Common.php
    Line Number: 409

    {test_message}

    I suspect there’s something simple I’m overlooking. Does anyone see it?

  • #3 / Nov 21, 2011 8:57pm

    Rob Sanchez

    335 posts

    Yep, parse_variables expects a multi-dimensional array—an array of arrays. Think of it as rows returned from the database.

    So you should either use parse_variables_row,  or make your data look like this:

    $data = array(
        array(
            'test_message' => 'This is a test.',
        ),
    );
  • #4 / Nov 21, 2011 9:09pm

    jaydisc

    19 posts

    Awesome! Thank you!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases