Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to add codeigniter function at twig #27

Closed
waptik opened this issue Apr 8, 2017 · 4 comments
Closed

unable to add codeigniter function at twig #27

waptik opened this issue Apr 8, 2017 · 4 comments

Comments

@waptik
Copy link

waptik commented Apr 8, 2017

Hi i am using this library but facing a problem while trying to use functions. Question on SO is not mine but i am facing same problem. i have already loaded url and form helpers in my controller.
I hope someone can help.

my error

n uncaught Exception was encountered

Type: LogicException

Message: Unable to add function "base_url" as extensions have already been initialized.

http://stackoverflow.com/questions/41662788/unable-to-add-codeigniter-function-at-twig (reffered from SO)

@kenjis
Copy link
Owner

kenjis commented Apr 9, 2017

You don't have to add base_url, because this library does it.
See https://github.com/kenjis/codeigniter-ss-twig#supported-codeigniter-helpers.

@waptik
Copy link
Author

waptik commented May 6, 2017

Okay thanks, I got it working.

Also I have this issue . I added the widget() method your library as follow:

// libraries / Twig.php
.....
public function widget($name){
$this->_widget = '_includes.'$name.'.html';
return $this;
}

// in my controller/home.php
.....
public function index(){
$this->twig->addGlobal->('twig', $this->twig);
......
$this->twig->display('home');
}

// views home.php
{# let's include the header page #}

{% include twig.widget.header %}

{# end #}

............#

This is the error I get
A PHP Error was encountered
Severity: Warning
Message: Missing argument 1 for Twig::widget(), called in .......

@kenjis
Copy link
Owner

kenjis commented May 7, 2017

Do you want like this?

public function widget($name){
  return $this->_widget = '_includes.'$name.'.html';
}
{% include twig.widget(header) %}

@waptik
Copy link
Author

waptik commented May 7, 2017

Yes that's what I was working on. Do you know any idea how to achieve it?
UPDATE 1 : I tried your solution but I got this error :
An Error Was Encountered

Unable to find template "_includes/0.html" (looked into: /home/waptik/public_html/../..app/views/twig).

I don't know why it's 0.html and not header.html

UPDATE 2: I got it working with this {% include twig.widget('header') %}
Thanks for the hand.

@waptik waptik closed this as completed Jul 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants