Open RelativeMedia opened 12 years ago
Alas, I just wrote the same thing, not having seen this. I handled mine a little differently though.
how did you go about it?
You can see it on Pull request #39
Just added a few config files to enable/disable this, as well as the ability to reverse the array that the title is stored in before rendering.
the Template library currently supports title chaining within the same function.
This works great, but what happens if you have a controller that extends another controller and you want to define a title at each level but not have to pass each title parameter every time. e.g';
This is where i began editing code.. I'm sure theres a cleaner way of doing it, if not.. let me know and ill submit a pull request for the change.
i modified the Template.php library for my own use, and it works..
Template.php
New Function: site_title This function is responsible for compiling the title from an array, just like
title( 'title1', 'title2', 'title3' )
normally would. Except this will check if the class object$this->_titles
has more than one item, if it does then it will implode them all, otherwise it will just return back the first element(0).Modified function: title I modified this function to actually push the passed
$title
to the class object$this->_titles
. This way the code in your controllers, does not have to be changed.Modified function: build I then modified the build function to set the title to the
set_title()
function, which returns either the imploded array of titles, or the single title.Like i said, i modified this for my own use. However i would be more than happy to submit a Pull Request if Phil decides to merge it into his library.
Full Code of Template.php