Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter Simple and Secure Twig
#21

Hi, awesome work, Is there a way to use CI helpers, like form_label, form_input also, I can see form_open,form_close are already in your list.
Reply
#22

If you want to use CI helpers which are not supported, you can post issuse on GitHub.

Probably you can use Form helpers if you add the helper names in the following line:
https://github.com/kenjis/codeigniter-ss...ig.php#L25
Reply
#23

I think this is awesome library Kenji!

Is there any way in Codeigniter 3.x to render a twig template from within a twig?

For instance if I had inside my twig something like... 


{{ render('season_controller/champions', {'season_id': season.season_id}) }}

It would call my controller and display the output inside the twig. 
If I could do this it would be awesomely handy.
Is this possible?
Reply
#24

(02-21-2016, 06:15 PM)thocutt1020 Wrote: I think this is awesome library Kenji!

Is there any way in Codeigniter 3.x to render a twig template from within a twig?

For instance if I had inside my twig something like... 

{{ render('season_controller/champions', {'season_id': season.season_id}) }}

It would call my controller and display the output inside the twig. 
If I could do this it would be awesomely handy.
Is this possible?

That is calling another controller (from a contorller). CodeIgniter does not support it.
It is limitation (and design) of CodeIgniter.

To make it possible, first, you have to hack CodeIgniter. And I don't
recommend it unless you are an expert of CodeIgniter.
Reply
#25

(02-21-2016, 09:41 PM)kenjis Wrote:
(02-21-2016, 06:15 PM)thocutt1020 Wrote: I think this is awesome library Kenji!

Is there any way in Codeigniter 3.x to render a twig template from within a twig?

For instance if I had inside my twig something like... 

{{ render('season_controller/champions', {'season_id': season.season_id}) }}

It would call my controller and display the output inside the twig. 
If I could do this it would be awesomely handy.
Is this possible?

That is calling another controller (from a contorller). CodeIgniter does not support it.
It is limitation (and design) of CodeIgniter.

To make it possible, first, you have to hack CodeIgniter. And I don't
recommend it unless you are an expert of CodeIgniter.

Thanks for your response!
I see what you are saying...
maybe I can get the functionality I want by creating helper functions and then calling them from within the twig. I will try that.

One other question I was wondering about.
With views, you used to be able to store the output in a variable i.e..
 $string = $this->load->view('myfile', '', true);

Can you achieve same result with twig?
 $string = $this->twig->display('myfile.html', '', true);
Reply
#26

(02-21-2016, 11:26 PM)thocutt1020 Wrote: Thanks for your response!
I see what you are saying...
maybe I can get the functionality I want by creating helper functions and then calling them from within the twig. I will try that.

I know a few solutions. One is HMVC.
Another is widgets: https://github.com/kenjis/codeigniter-widgets

If you really need to call another controller, I don't recommend to use HMVC.
Because it brings complexity to CodeIgniter. But HMVC is very popular library for CodeIgniter.
Reply
#27

(02-21-2016, 11:26 PM)thocutt1020 Wrote: One other question I was wondering about.
With views, you used to be able to store the output in a variable i.e..
 $string = $this->load->view('myfile', '', true);

Can you achieve same result with twig?
 $string = $this->twig->display('myfile.html', '', true);

See https://github.com/kenjis/codeigniter-ss...-templates

You can use `render()` method:
$output = $this->twig->render('welcome', $data);
Reply
#28

I sent PR to add user functions.
See https://github.com/kenjis/codeigniter-ss-twig/pull/8
Reply
#29

I've just released v0.2.0: https://github.com/kenjis/codeigniter-ss-twig/releases

Now you can add your functions with configuration.
Reply
#30

Hello,
In doc it is written :
You can override the default configuration:


PHP Code:
$config = [
   'paths' => ['/path/to/twig/templates'VIEWPATH],
   'cache' => '/path/to/twig/cache',
];
$this->load->library('twig'$config); 


That is clear, but I load twig in autoload file, as :

PHP Code:
$autoload['libraries'] = array('ion_auth''twig' ); 


How to overwrite config in this case?

  Thanks!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB