Welcome Guest, Not a member yet? Register   Sign In
How to make custom helper work.
#3

[eluser]razerone[/eluser]
[quote author="Tpojka" date="1390146085"]You have somewhere to define those elements. For example, in first code you've posted above, you defined
header as $this->load->view('theme/default/template/common/header.tpl'),
so it is clearly to interpreter to use header value. If you want to override native Loader function, I've seen already in some starting packages, such as skeleton too (find it on github typing 'codeigniter skeleton'), there are included such files in core folder.
Anyway, you need to override view method from Loader.php file, especially $vars array parameter of method and the way how method is reding it. Method is on line 417.
So you can make your class in application/core folder with custom overriding method.

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Loader extends CI_Loader
{
  public function construct__()
  {
    parent::__construct();
  }

  public function view($view, $vars = array(), $return = FALSE)
  {/* you have to change this part to response your needs : this is copied function from Loader.php
    return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));*/
  }
}

I would like someone with more experience than myself to leave post here and say if I am wrong.[/quote]

With my arrays the top example is working but only want to be able to put example 'header' rather than long way just like open cart template engine.


Messages In This Thread
How to make custom helper work. - by El Forum - 01-19-2014, 07:22 AM
How to make custom helper work. - by El Forum - 01-19-2014, 08:41 AM
How to make custom helper work. - by El Forum - 01-19-2014, 08:53 AM
How to make custom helper work. - by El Forum - 01-19-2014, 10:26 AM
How to make custom helper work. - by El Forum - 01-19-2014, 10:08 PM
How to make custom helper work. - by El Forum - 01-20-2014, 02:37 AM
How to make custom helper work. - by El Forum - 01-20-2014, 02:58 AM
How to make custom helper work. - by El Forum - 01-20-2014, 03:22 AM
How to make custom helper work. - by El Forum - 01-20-2014, 03:38 AM
How to make custom helper work. - by El Forum - 01-20-2014, 03:55 AM
How to make custom helper work. - by El Forum - 01-20-2014, 04:13 AM
How to make custom helper work. - by El Forum - 01-20-2014, 05:44 AM
How to make custom helper work. - by El Forum - 01-20-2014, 06:21 AM
How to make custom helper work. - by El Forum - 01-20-2014, 08:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB