Welcome Guest, Not a member yet? Register   Sign In
Introducing the Template Library
#11

[eluser]Colin Williams[/eluser]
Quote:wouldn’t it be handy if we could pass it view files too?

Well, if you're views aren't dynamic (they don't require data being passed in), then there's really no reason to not just include them in the master template, like, not separate them out into their own files. I guess there could be a reason to share Views among different templates like that, though, in which case it makes since to separate them out. I will certainly consider it.
#12

[eluser]Colin Williams[/eluser]
Quote:Yeah, I think I could confused because you first talk about template->load. Load is most of the time a command you use first in CI.

That is a really good point. I'm going to consider a different method name for that.
#13

[eluser]Bramme[/eluser]
[quote author="Colin Williams" date="1217459440"]
Quote:wouldn’t it be handy if we could pass it view files too?

Well, if you're views aren't dynamic (they don't require data being passed in), then there's really no reason to not just include them in the master template, like, not separate them out into their own files. I guess there could be a reason to share Views among different templates like that, though, in which case it makes since to separate them out. I will certainly consider it.[/quote]

Hmm, true, I could leave out the footer in my case, since it's just static HTML, however, I build my navigation with the help of an array I set in the construct, that way it's easy to create a css based navigation with hovers and an "active link" state.


Edit: I found a bug. If you set $config['compress_output'] to TRUE in your config file, Firefox throws an error: I get a warning it can't display the page because there's smth wrong with the compression. Conflicting caching maybe?

Well, maybe it's not a bug, maybe it's just a given fact, but then it should be documented Wink
#14

[eluser]Colin Williams[/eluser]
Quote:however, I build my navigation with the help of an array I set in the construct, that way it’s easy to create a css based navigation with hovers and an “active link” state.

You could have a $menu region that gets written to in the constructor.

Quote:If you set $config[’compress_output’] to TRUE in your config file, Firefox throws an error: I get a warning it can’t display the page because there’s smth wrong with the compression. Conflicting caching maybe?

For one, there should be no $config items in config/template.php. And it's not a caching issue, it's a gzip compression issue. Template is just an interface to Views. It does nothing to rewrite CI's output procedures. Check to see if compression works without using Template. I have a feeling it could be a problem with your servers gzip library.
#15

[eluser]Colin Williams[/eluser]
Okay, after some quick testing, I can ensure Template does not affect output compression nor caching. whew!
#16

[eluser]Bramme[/eluser]
Yeah, I know that there's no need for $config items in template.php, I was talking about the general config.php file :p

And it used to work without template. Odd. I only noticed because I set it to TRUE a while back for my application and I got the error for the first time when using template. Could be a coincedence though... I'll have to test later.

About the $menu region: that'd be the same amount of code as simply writing $data to my $header section :p I still think I should be able to send a view along in the config file.

Though I just realised, then I'd have to replace my template->write line with a load->vars, because my view would be helpless without the $data array. Dang. No need for view files after all :p
#17

[eluser]Colin Williams[/eluser]
Quote:because my view would be helpless without the $data array

Good recognition! It's probably not something I'll implement. There are a few ways to globally write to your template regions:

1.) Write from the Controller constructor
2.) Extend CI_Controller and write from your MY_Controller constructor
3.) Write from a Hook that runs before output
4.) Write from a Library that is autoloaded (NOT a recommendation, unless you use a Library specifically for extra bootstrapping)

For dynamic menus, I have a menu library that generates the menu. Then, in a hook, I call the menu lib to build the menu, then write its result to a region.
#18

[eluser]codex[/eluser]
[quote author="Colin Williams" date="1217459553"]
Quote:Yeah, I think I could confused because you first talk about template->load. Load is most of the time a command you use first in CI.

That is a really good point. I'm going to consider a different method name for that.[/quote]

$template->serve() maybe?
#19

[eluser]Colin Williams[/eluser]
I'm thinking display() or output(). There is already an undocumented display() method that will output or return the given region, but if I go with display() I'll just rename that one to load_region()

The way the API reads is as important as anything. What do yall suggest between load() initiate() serve() display() or output(), or anything else?
#20

[eluser]codex[/eluser]
[quote author="Colin Williams" date="1217483089"]I'm thinking display() or output(). There is already an undocumented display() method that will output or return the given region, but if I go with display() I'll just rename that one to load_region()

The way the API reads is as important as anything. What do yall suggest between load() initiate() serve() display() or output(), or anything else?[/quote]

load() initiate() and output() are used within the CI framework and could therefore be confusing, so I'd say serve() or display().




Theme © iAndrew 2016 - Forum software by © MyBB