Welcome Guest, Not a member yet? Register   Sign In
Twiggy - Twig template engine implementation
#11

[eluser]ghprod[/eluser]
Hi,

how to display elapse_time and memory_usage in twig template?

thanks
#12

[eluser]helia_Dar[/eluser]
Duplicate post - please see below
#13

[eluser]helia_Dar[/eluser]
Hey great work on Twiggy. I'm new to CI and having a bit of trouble figuring out how to implement. I've downloaded your example code from:
Demo (example) application: https://github.com/edmundask/codeigniter-twiggy-demo

I'm having trouble understanding how I should modify a standard CI view to pull a template.

In your demo app, you have the "factory default" welcome_message view.

It would be very helpful if you could repost the project with the welcome_message view using the twiggy template.

Or... a quick note on what changes are needed to the view / controller to pull the content properly.


Currently I have modified my view to just have the body content and have put the follow code in my welcome controller:
Code:
$this->load->view('welcome_message');
$this->twiggy->display();
I get the twiggy template rendered and then after the html close tag, the modified welcome_message - which is obviously not right.

Sorry about what I'm sure to be a very obvious oversight and ty for the help.
#14

[eluser]helia_Dar[/eluser]
So a couple things I figured out for all you other newbies.
1) A default non-wamp install of apache does not recognize .htaccess files which are required for most CI demos to remove the index.php. Editing of the httpd.conf file is required.

2) urls to access the twiggy views in the demo app are:
/articles
/articles/view_with_sidebar

3) Actual twiggy logic for demo is found in:
/application/modules/articles/

4) Forget about CI views with Twiggy. Twiggy templates = CI views.
#15

[eluser]ZaLiTHkA[/eluser]
[quote author="helia_Dar" date="1353778505"]So a couple things I figured out for all you other newbies.
1) A default non-wamp install of apache does not recognize .htaccess files which are required for most CI demos to remove the index.php. Editing of the httpd.conf file is required.

2) urls to access the twiggy views in the demo app are:
/articles
/articles/view_with_sidebar

3) Actual twiggy logic for demo is found in:
/application/modules/articles/

4) Forget about CI views with Twiggy. Twiggy templates = CI views.[/quote]
It seems this thread isn't all that active any more, but just to clarify a bit on these points..

1) Whether .htaccess works or not has nothing to do with WAMP or LAMP, it relies on an Apache specific setting. If your (L/W)AMP stack is not obeying rules set in your .htaccess file, check the AllowOverride directive in your Apache configuration.

3) This is not because of Twiggy, but rather because the example in question uses Wiredesignz's HMVC modification, you'll see his files in the /application/third_party/MX/ folder.

4) Don't forget about default CI Views, Twiggy templates != CI Views. As stated in the Twiggy readme file, it doesn't replace the default methods, so you can still use them side by side without any problems. For example, for maintenance pages, "still under construction" pages or (if you use them) landing pages.

Hope that helps clarify things a little bit... And of course, happy Twigging. Smile
#16

[eluser]ZaLiTHkA[/eluser]
@Edmundas, hope you're still watching this thread... I have a question regarding your Twiggy implementation of Twig. I've been trying to understand how the '_layouts' folder fits into Twig, but I'm getting slightly confused here.

On your Twiggy page you give the example folder structure as:
Code:
+-{APPPATH}/
| +-themes/
| | +-default/
| | | +-_layouts/
| | | | +-index.hml.twig
| | | +-index.html.twig

Then the 'index.html.twig' file outside the '_layouts' folder starts with:
Code:
{% extends _layout %}

Looking at the Twig documentation (specifically this page), I can't seem to find any examples of using 'extends' to reference a folder, only to reference files. Did you perhaps extend the 'extends' side in your implementation? Or am I perhaps missing some important point in the documentation?

Currently I'm running Twiggy with a folder structure of:
Code:
+-{APPPATH}/
| +-themes/
| | +-default/
| | | +-base/
| | | | +-layout.hml.twig
| | | +-index.html.twig

Then starting my index.html.twig file with:
Code:
{% extends "base/layout.html.twig" %}

This works perfectly for me, but I can't help but wonder if I'm missing out on some fancy feature here...
#17

[eluser]Edmundas KondraĊĦovas[/eluser]
Hi there,

sorry for not responding to this sooner, I haven't really touched PHP in a long while.

Anyway, this line should explain a lot: https://github.com/edmundask/codeigniter...y.php#L337

So simply put, _layout is just a variable that you should use in your templates. It allows you to set the layout from the controller (or somewhere else in your PHP code), instead of doing it manually in the template.




Theme © iAndrew 2016 - Forum software by © MyBB