Welcome Guest, Not a member yet? Register   Sign In
help templates
#1

[eluser]zyklon[/eluser]
Hi.Can someone help me with sending arrays to templates?I can't make the arrays right.I pay.
#2

[eluser]aart-jan[/eluser]
Have you read the user guide on templates?
It's explained there:
http://ellislab.com/codeigniter/user-gui...arser.html

Code:
<html>
<head>

</head>
<body>



{blog_entries}
<h5>{title}</h5>
<p>{body}</p>
{/blog_entries}
&lt;/body&gt;
&lt;/html&gt;
The $blog_entries variable is the array, and body and title are the indices of that array.
#3

[eluser]zyklon[/eluser]
Yes but i am talking about template that looks like:
{specification_categories}
<div class="specs">
<div class="blue_11_bold"><span class="specs_title">{specification_category_name}</span></div>
{subspecifications}
<div class="specs_gray">
<div class="specs_left">{subspecification_name}</div>
<div class="specs_right">{subspecification_value}</div>
</div>
{/subspecifications}
</div>
{/specification_categories}

So 2 loops
#4

[eluser]aart-jan[/eluser]
If the template parser does not support nested arrays I think best solution would be to move the subspecfications to a seperate template and use this wiki page on usage of multiple templates to achieve your desired result: http://codeigniter.com/wiki/Displaying_M...Templates/
#5

[eluser]esra[/eluser]
[quote author="aart-jan" date="1196975768"]If the template parser does not support nested arrays I think best solution would be to move the subspecfications to a seperate template and use this wiki page on usage of multiple templates to achieve your desired result: http://codeigniter.com/wiki/Displaying_M...Templates/[/quote]

bTemplate is a light template library that does support nested loops, conditionals, and a few other features not supported by Parser. After installing bTemplate.php in application/libraries, you can load it like any other library. If you do a search on the forums, you should get some hits with examples of usage.
#6

[eluser]zyklon[/eluser]
I am trying to use bTemplate,but i am getting an error:
Unable to load the requested class: btemplate

The code is:
Code:
$this->load->library('bTemplate');  

         $base_path = $url_path . "/lugnuts/application/views/site/components/";

         $ldelim = "{";
         $rdelim = "/}";
         $ldelim = '{';
         $rdelim = '/}';
         $BAldelim = '{';
         $BArdelim = '/}';
         $EAldelim = '{';
         $EArdelim = '/}';

         $tpl = new bTemplate();

         $tpl->set('url_of_site', $url_path);
         $tpl->set('category_name', $category_name);
         $tpl->set('category_id', $id_category);
         $tpl->set('subcategory_name', $subcategory_name);
         $tpl->set('subcategory_id', $id_subcategory);
         $tpl->set('product_image', $product_image_path);
         $tpl->set('product_name', $product_name);
         $tpl->set('product_id', $id_product);
         $tpl->set('product_description', $product_description);
         $tpl->set('regular_price', $url_path);
         $tpl->set('url_of_site', $regular_price);
         $tpl->set('sale_price', $sale_price);
     print $tpl->fetch('product.html');
#7

[eluser]esra[/eluser]
Take a look at this thread for sample code.

http://ellislab.com/forums/viewthread/47981/
#8

[eluser]zyklon[/eluser]
Actually the problem was that the first letter of the library name must be capitalized.Like Btemplates not bTemplates.




Theme © iAndrew 2016 - Forum software by © MyBB