Welcome Guest, Not a member yet? Register   Sign In
Template Library Version 1.4
#81

[eluser]Colin Williams[/eluser]
Thanks, Tony.

Quote:With this lib, is it possible to call controllers from view?

Well, for one, I don't think that is the best architecture for any app that wants to adhere to MVC. There are differing opinions and no reason to debate them here. But regardless, Template does not do this.

If you do want to directly call Controller methods in such a fashion, look at either [url="http://codeigniter.com/wiki/Modular_Extensions_-_HMVC/"]Modular Extensions -HMVC[/url] or [url="http://codeigniter.com/wiki/Wick/"]Wick[/url].
#82

[eluser]Tony Nash[/eluser]
Thanks for the reply Colin. Basically, I wanted know if this lib support view Partials (blocks) someway?
#83

[eluser]Colin Williams[/eluser]
By utilizing a region-based system, I think Template is a great foundation for implementing a blocks (or "partials") system in your app.

Imagine a hook or autoloaded library or other global actor that polls the database to retrieve all blocks for the given request. The blocks table could have a 'region' column, so in your block hook or library, et. al., it would iterate over the returned blocks and $this->template->write($row->region, $row->content) for each one. This would be more flexible and better design because block visibility and placement is managed in the database, not in the source code, which is how ME - HMVC and Wick suggest you do it.
#84

[eluser]vendiddy[/eluser]
Hi Colin. I wanted to thank you for the development of this library. It has helped me make my views a lot cleaner.

I have two feature suggestions and would like to know what you think of them:

1. Get asset urls from the config.
I think it would be convenient if I were able to set the base paths of my css directory and js directory in a config file. For example:
Code:
$assets['js'] = 'resources/js';
$assets['css'] = 'resources/css';
$assets['jquery_plugins'] = 'resources/js/jquery/plugins';
'js' and 'css' would be the default base paths for the add_js and add_css functions. If I wanted to add a jquery plugin js file, I could set the optional location argument to 'jquery_plugins'.

2. Allow minification of assets.
I think it would be useful if there was an option to compress & combine the css and js files. Maybe this feature could be pluggable in the same way the template parsers are. Then someone could integrate JSMin and CSSTidy.
#85

[eluser]Colin Williams[/eluser]
Thanks, vendiddy. I haven't had much time to work on Template, but I initially like your suggestions. I'll PM you if I have any questions.
#86

[eluser]tdktank59[/eluser]
I don't think anyone has posted anything about using Modular Extensions with this.

So here is the question.

How would you move the files to maintain the HMVC.

modules
- template
- - config
- - - template.php
- - libraries
- - - template.php
- - views
- - - template.php

Im confused and I havn't played with it yet but plan to. Just wanted to see what the official method was to make this work with HMVC

Also Wanted to note that I like what you have done! Exactly what I was looking for!
#87

[eluser]Colin Williams[/eluser]
One thing that should be understood is Template is a Library, and it is intended to be placed at application/libraries/template.php

Components of ME - HMVC can still, as far as I understand, use libraries located in application/libraries. So, I think the problem is that you are thinking an HMVC "module" is the same thing as a "library."

And finally, all Template does is load views with the $CI->load->view() method. So, unless the HMVC solution you are using rewrites or otherwise alters this method, Template should work (you will probably need your master template file in application/views and not modules/module_name/views).
#88

[eluser]tdktank59[/eluser]
Simple enough.

Thanks for the explanation
#89

[eluser]tdktank59[/eluser]
Here is an idea for a future version...

I'm going to be working on making it work so give me a few days to play with this idea and I may have a "fix" for it.

Instead of just using the views folder to house the templates, allow for sub folders
for example

views -> templates -> {template name} -> {template name . ext}

This way you can nest templates together.
Just like with the loading libraries etc... you can do auth/login or something to that nature.

This way you have have multiple files for a template: images, css, and so on. all contained in one folder. In a sense making the templates more modular in general. (Letting you just drop a new template into the views/templates folder.

=====

Like I said above I'm going to work on this for myself since the project I'm working on required multiple templates within the same application and I like to keep my codes separate from each other (ie css, js, html, images....)

So let me know what you think I'll post up the modified code when I get it to work.




Update:

allright started looking into this... Its a bit harder than I imagined... However It could be possible, You would have to somehow set a variable to set as the "root" for the templates in the config to use when you called images, css etc...

Seems like a bit more work then it should be...
#90

[eluser]Colin Williams[/eluser]
You can set $template['default']['template'] to 'themes/defualt/page.php', for example, then your app just needs a global 'theme' directory variable that it always sends to write_view(), parse_view(), etc. All you really need to do is 1) maintain the variable holding the directory, and 2.) have your 'themes' under 'application/views'

This is how I've done it before.

Code:
$this->template->write_view('content', config_item('theme_dir'). 'blog', $data);

If you wanted template to handle this (meaning you are turning the Template library into a Theming library, of sorts) I would recommend adding a set_theme() method to the Template class, et. al. (I actually had this working in Template at one point but decided ultimately that it was shifting the role of the library to a broader scope, which I didn't necessarily want)




Theme © iAndrew 2016 - Forum software by © MyBB