Welcome Guest, Not a member yet? Register   Sign In
Solution for JS, AJAX, templating for CI
#1

[eluser]Unknown[/eluser]
Someone has to take the rains on this topic... My proposed solution is to take some ideas from smartyCMS approach. by doing such we can keep js logic and CSS logic separate from php logic, and make everything JS framework independent.

my ideas would be, if ajax is to be used, simply make a MY_AJAX model that will be loaded to any control that may have ajax, so all Ajax logic and what ever lexicon created can be defind by the user there (or have a few already made for use with JSQuery dojo and so on) then create another directory structor for Views to be such like:

Code:
Application
  |
  +-Config
  +-Controlers
  +-Modules
  | +AJAX.php [the logic funtions for ajax comunication]
  |
  +-Helpers
  | +CSS.php [functions like css_define_id("#sidebar_clock",[widgetname]) os JS wrappers ]
  |
  +-Libraries
  +-Hooks
  |
  +-Views
    |
    +-Assets/includes [common elements]
    | |-CSS
    | |-IMAGES
    | |-JS
    |
    +-Widgets [templates to menubars/sidebars anything to plug in]
    |
    +-Templates [each version of a site]
    | |
    | +Default_Name
    |  |-Assets  
    |  |-CSS
    |  |-JS

Example of a Controller:
Code:
class Customers extends Controller {

        function __construct() {
                parent::Controller();
                $this->load->model('customers');
                $this->output->enable_profiler(TRUE);
        }

        function index()
        {

              $CU_data = $this->db->get('customers');
              $curtime = getdate();
              $w_time['css'] = array(
                                                       'id' => 'currtime'
                                                       'name' = 'currtime' );
              $w_time['data'] = array(
                                                        'data' => getdate();
                                                        'title' => 'The current Date' );
             $data[widget_time] = $w_time;
             $data .= $CU_Data;
             $this->view->('templates/Default/index',$data);
       }

       function AJAX()
       {
              $this->load->model('AJAX');
              $this->ajax->execute_action();  //logic for action or $this->[action]();
      }

     function ADD()
     {
            if($this->ajax)
            {
               $this->db->insert('customers') = $this->ajax->data();
               $this->ajax->return_succsess();
               $this->ajax->inerhtml_by_id('#status_message', '<B>ADDED</A>');

            } else {
               $this->db->insert('customers') = $this->posts;
               $data = array('message','Added');
               $this->view('templates/Default/add',$data);
            }
     }

}

Example of a Widget(filename: standard_dialogbox.widget)
Code:
<div id={$css[id]}>
     <B>{$data[title]}</b><BR>
     {$data[data]}
</div>


Example of Template(filename: add.php):


Code:
{include: file='header.php'}
So this is my dialog box with a widget
{widget: 'standard_dialogbox.widget',$w_time}
{include: file='footer.php'}


extremely tired Will edit post with more examples, but i think this gives the direction


Messages In This Thread
Solution for JS, AJAX, templating for CI - by El Forum - 06-15-2010, 11:46 AM
Solution for JS, AJAX, templating for CI - by El Forum - 06-16-2010, 10:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB