Part of the EllisLab Network
   
2 of 24
2
Template Library Version 1.4.1
Posted: 05 November 2008 04:52 AM   [ Ignore ]   [ # 11 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  133
Joined  06-06-2008

On another note just found this link: http://www.artofscaling.com/css-minifier/

Might be something to look into.

 Signature 

Milos Dakic

Profile
 
 
Posted: 05 November 2008 11:06 AM   [ Ignore ]   [ # 12 ]  
Grad Student
Rank
Total Posts:  78
Joined  10-16-2008

Quick question for you. I really love the template library that you have but I am wondering how can I make the header and footer dynamic? I want to display certain sections in the header and footer of the page.

I dont’ want the current controller being called to render the header and footer as well. Is there a way to automatically call a certain view/controller to render header and footer?

thanks

Profile
 
 
Posted: 05 November 2008 02:47 PM   [ Ignore ]   [ # 13 ]  
Lab Technician
RankRankRankRank
Total Posts:  1040
Joined  06-19-2007

Colin,

This time my question is directly relevant to Templating! wink

The concept of add_region() is so fundamentally brilliant, and brilliantly simple it is astounding.  That one method could allow modularity through simplicity like CI has not seen before.  I know you realize this because you’ve discussed it in so many threads.  I’ve just now grasped your vision.  So here is my next question…

Will you consider adding a parameter to add_region()?  That parameter would be $before=null if(null) then drop on the end of the stack, otherwise insert region in stack before $before.

That would provide us finer grained control over the output…and create a modularize application development environment. We don’t need HMVC if we have a simple template driver that allows us to insert content dynamically into the view.

The simplicity here makes this a very approachable solution that is easy to understand, adopt and implement.

What say you?  It’s on a hand full of LOCs.

Randy

 Signature 

My new therapist is working with me every day, the third one gave up… ohh

Profile
 
 
Posted: 05 November 2008 04:48 PM   [ Ignore ]   [ # 14 ]  
Grad Student
Rank
Total Posts:  78
Joined  10-16-2008

Randy: Can you explain a bit more about add_region() function? I am not sure if i understood it after reading the documentation.

An example would be nice smile

Profile
 
 
Posted: 05 November 2008 06:26 PM   [ Ignore ]   [ # 15 ]  
Lab Technician
RankRankRankRank
Total Posts:  1040
Joined  06-19-2007

Here’s what I was thinking…I wrote a class to over ride Colin’s class while he decides if this is something he would like to pursue.  Here is a replacement for add_region():

/**
    * Dynamically add region to the currently set template
    *
    * @access  public
    * @param   string   Name to identify the region
    * @param   array  Optional array with region defaults
    * @param   string Optional string region name to deposit this new region before in stack
    * @return  void
    */
   
   
function add_region($name$props = array(), $before null)
   
{
      
if ( ! is_array($props))
      
{
         $props 
= array();
      
}
      
if ( ! isset($this->regions[$name]))
      
{
          
if ( $before === null)
          
{
             $this
->regions[$name] $props;
          
}
          
else
          
{
             $pos 
array_search($before,array_keys($this->regions));
             
$this->regions array_merge(array_slice($this->regions,0,$pos), array( $name => $props ), array_slice($this->regions,$pos));
          
}
      }
      
else
      
{
         show_error
('The "'$name .'" region has already been defined.');
      
}
   } 

Now with this, you can dynamically add regions just like Colin has provided.  But with the additional parameter you can place the regions in the array stack relevant to where it shows up on the page. (it could be argued that with CSS this is a moot point.)

So now you could add widgets to your left panel, right panel, footer, header, banner, change you content region into a paneled region etc.  This becomes relevant when thinking about user roles and access rights.  Logically, you now can dynamically add and remove regions based upon the access rights of the person logged in.

You get the idea.

To implement this, the call would look like this:

$this->template->add_region('myNewRegion','','footer'); 

This would add a new region in output page (in the regions stack) above the footer.

Hope the explains what I meant.

Randy

 Signature 

My new therapist is working with me every day, the third one gave up… ohh

Profile
 
 
Posted: 05 November 2008 06:30 PM   [ Ignore ]   [ # 16 ]  
Lab Technician
RankRankRankRank
Total Posts:  1040
Joined  06-19-2007

Colin if you want to PM me about where I’m headed with this, please feel free.  You’re likely to be miles ahead of me, but I would like to open the door none the less.

Randy

 Signature 

My new therapist is working with me every day, the third one gave up… ohh

Profile
 
 
Posted: 05 November 2008 07:33 PM   [ Ignore ]   [ # 17 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  801
Joined  04-20-2006

A quick question to you, not related to your template class but more of CI.

About: “Renamed the Template class to CI_Template. This means Template can be replaced/overloaded like core CI classes, and also allows you to have a template.php controller.”

This mean I can overide your library using a MY_Template.php file, right? Out of this point, what are the benefits to have a library as a core class?

 Signature 

Un blog seo white-hat expliquant quelques techniques intéressantes sur le seo black hat

Ionize CMS - Webdesigner CMS based on CodeIgniter
www.ionizecms.com

My website: Webagency Too Pixel

Profile
 
 
Posted: 05 November 2008 07:57 PM   [ Ignore ]   [ # 18 ]  
Lab Technician
RankRankRankRank
Total Posts:  1040
Joined  06-19-2007

@Too pixel - This is not my question to answer, but I’m confused my this wording…

what are the benefits to have a library as a core class?

Do you mean like the Exception class, or Controller class, or Hooks class, etc?  These are all libraries that exist as core classes.

It would seem the naming convention simply provides flexibility.  In the last few posts you’ve seen where I’ve overridden Colin’s work.  His use of names simply made this easier and made the conventional use of CI ‘feel’ more like CI.

Where they go and what they are called is just a symantic game maybe?

Randy

 Signature 

My new therapist is working with me every day, the third one gave up… ohh

Profile
 
 
Posted: 05 November 2008 08:36 PM   [ Ignore ]   [ # 19 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  801
Joined  04-20-2006

No I don’t mean those already existing core libs, I was meaning about creating new libs using CI_Someclass.

I was just wondering because I discovered thanks to Colin’s library that I can use CI_Someclass to name my libs if I want them to be part of CI’s Core. I missed that point on CI user guide, so I would just like to know what benefits can be.

 Signature 

Un blog seo white-hat expliquant quelques techniques intéressantes sur le seo black hat

Ionize CMS - Webdesigner CMS based on CodeIgniter
www.ionizecms.com

My website: Webagency Too Pixel

Profile
 
 
Posted: 05 November 2008 08:50 PM   [ Ignore ]   [ # 20 ]  
Lab Technician
RankRankRankRank
Total Posts:  1040
Joined  06-19-2007

Oh…OK, well for me, Colin has done great work.  Just like CI, though, I need a little extra out of it.  Now I can extend it just like other CI classes.  The alternative is to fall back to traditional include() or require() statements.  This would just as well work too I suppose.  It just wouldn’t bee like CI.

I think there would be more potential for name conflicts too.

Hope that helps.

Randy

 Signature 

My new therapist is working with me every day, the third one gave up… ohh

Profile
 
 
   
2 of 24
2