CodeIgniter Forums
Template Library Version 1.4.1 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Template Library Version 1.4.1 (/showthread.php?tid=12840)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24


Template Library Version 1.4.1 - El Forum - 06-15-2010

[eluser]kpspoke[/eluser]
when i try and use the add_js() function it errors out. I add the regions $_scripts to the template header file but when i load the page it says undefined variable _scripts.

any thoughts?

Thanks

[edit]

changed <?= $_scripts ?> to <?= (isset($_scripts)) ? $_scripts : “”;

and obviously i lose the error but the js file still isnt loading.

[edit2]

I did an echo at each step though the add_js() method and the output is correct. I also did an output of $this->js and they both had the corret output. But i dont get anything added to the actual page.


Template Library Version 1.4.1 - El Forum - 06-28-2010

[eluser]broofa[/eluser]
First, thanks for making a clean and compact template library. It's been a pleasure to use. However, I've run into a use case that's giving me some problems, and I'd appreciate some advice on how best to solve it. Basically, I'd like to include a subview from within another view, kind of like how Rails' "partials" work.

Here's the specific use case: The app I'm writing is essentially a blog app, where users can create entries and leave comments. There are several views in the app where I'd like to be able to render comments (blog entry, user profile, main home page, etc.). Thus, I'd like to have a single snippet of markup for a "comment list" that is defined in a "comment_list.php" file (greatly simplified here):

Code:
<ul class="comments">
  &lt;? foreach ($comments as $comment) {
    <li class="comment">&lt;?= $comment->body ?&gt;</li>
  &lt;? } ?&gt;
</ul>

Then from within the different views, I'd like to include that file by doing something like this:

Code:
<p>blah blah content goes here blah blah </p>
&lt;?
$this->template->include('_comment_list', array('comments' => $user->comments));
?&gt;
<p>blah blah more content goes here blah blah </p>

Is this possible with Template? If so, how?


Template Library Version 1.4.1 - El Forum - 06-30-2010

[eluser]KevinSjoberg[/eluser]
I noticed that there was no support for declaring the media-type of a css file when using the import method
Code:
$this->template->add_css('path', 'import', 'mediatype')

generates:
Code:
&lt;style type="text/css"&gt;
   @import url(url_to_css_file);
&lt;/style


Also, it would be really great if you could post multiple CSS files with the same add_css() function. That is, set the properties in the form of an array.

could this be added in an upcoming version?


Template Library Version 1.4.1 - El Forum - 07-08-2010

[eluser]Unknown[/eluser]
Great library, but I have one question.

You have an example in the documentation where you only ever use one header and footer for a template, so you configured:

Code:
$template['default']['regions']['header'] = array('content' => array('<h1>CI Rocks!</h1>'));
$template['default']['regions']['footer'] = array('content' => array('<p id="copyright">© Our Company Inc.</p>'));

Is there a way to do this, except to grab a view file instead of just putting text in the config file itself?


Template Library Version 1.4.1 - El Forum - 07-09-2010

[eluser]reikje[/eluser]
I am pretty new to both Codeigniter and Template Library. One question I have is regarding use of multiple controllers. If I understood correctly, the standard way is to have 1 controller calling write_view multiple times. Unfortunately this controller would have to prepare all the data for the different regions (header, menu, content, footer etc.). Is it possible to have one controller per region/view? If so, how would you implement this scenario?


Template Library Version 1.4.1 - El Forum - 07-16-2010

[eluser]tunesmith[/eluser]
For partials, use $this->load->view. For instance, from a controller, I recently used this:

Code:
$this->data['order_summary'] = $this->load->view('public/join/order_summary', $this->data, TRUE);



Template Library Version 1.4.1 - El Forum - 07-18-2010

[eluser]Flynn[/eluser]
How about adding 'external' type for add_js/add_css in template library?
Something like that:
Code:
case 'external':
            $filepath = $script;
            $js = '[removed][removed]";
            break;



Template Library Version 1.4.1 - El Forum - 07-26-2010

[eluser]parham90[/eluser]
I just downloaded the template library. Great job! However, it appears I can not use functions such as anchor() when setting the default region content. Is it possible to do this somehow for the sake of portability?

Thanks!


Template Library Version 1.4.1 - El Forum - 07-27-2010

[eluser]Gamesh[/eluser]
Templates library is really nice, but add_js method is missing an ability to add external javascripts, now you can only add inline js or local, hosted on the same domain.
if would be nice if you could add external as well, it isn't much of modification as well
just needs a third case:
Code:
case 'external':
         $filepath = $script;
         $js = '&lt;script type="text/javascript" src="'.$filepath.'"';
         if ($defer)
         {
        $js .= ' defer="defer" async="true"';
         }
         $js .= '&gt;&lt;/script&gt;';
         break;



Template Library Version 1.4.1 - El Forum - 07-28-2010

[eluser]jmanpa[/eluser]
Colin,

I've created a sample app to test your Template library, but for some reason when I run it, the default regions don't get filled in. Template.php has this:

....

$template['default']['regions']['footer'] = array(
'content' => array('c 2010 mycompany')
);
...

when I run it, I get this in the source from the browser, without the footer defaults substituted:

....
&lt;body&gt;
....
<div id="footer">
&lt;?= $footer ?&gt;
</div>
</div>
&lt;/body&gt;

....

I'm just testing your library at the moment, so the test is basic. I only have this in my controller:


$this->template->render();

Any ideas why default footers aren't showing up?

Thanks.