0

Kohana 3.2 with Kostache Mustache.

I'm new on this.

I have this in a view

$this->config = Kohana::$config->load('information');
 if(isset($this->config["techinfo"][Request::current()->param('product')]))
 {
 $response['techinfo']['param']=$this->config["techinfo"][Request::current()->param('product')]["param"];
 }

In Information.php, I have a lot of data, like name, value, param and other stuff. Don't ask me why. This file has only a simple return array with data information inside.

What this does: the name of the array value is the same the name of the url product. So if it is /brand/category/product-A, the information is from product-A, and if it is /brand/category/product-B is his information that comes.

Template file has only {{#product}}{{#techinfo}}{{param}}{{/techinfo}}{{/product}}> Saying again: Don't ask me why, but it works. I've got this site this way.

My problem: I need to use the same file to get information. I can do this, but only if I duplicate de data. And I don't want to do this.

In a newer view, but the $this->config = Kohana::$config->load('information'); it's the same. But how I got de data from there?

hakre
  • 193,403
  • 52
  • 435
  • 836
JGSilva
  • 120
  • 1
  • 1
  • 9

1 Answers1

0

To get a variable from your config, use this:

    $this->config = Kohana::$config->load('less');
    $path = $this->config->get('path');

Make sure you don't have a similar config filed in one of the modules that is overriding your config file. You may notice the wrong values in that case due to the HMVC.

gspatel
  • 1,128
  • 8
  • 12
  • Thanks a lot, I really got the data I did in View `public function faqinfo() { $this->config = Kohana::$config->load('supportinfo'); $path = $this->config->get('techinfo'); print("
    ");
     print_r($path);
     die('died');
     }`
    
    but the problem now is that it is bring all the data even doing this in his template.mustache
    
    `{{#faqinfo}}
    {{arrayName}}
    {{/faqinfo}}`
    
    
    i tried something like `$path = $this->config->get('techinfo')['arrayName'];`
    but, of course it did not work. 
    
    could you help me again?
    – JGSilva Mar 26 '12 at 13:08
  • can you send us the output of print_r($path) and can you also show me the line where you pass the variable from the controller to the view (something like $this->response->template->arrayName = $path['arrayName'])? – gspatel Mar 26 '12 at 14:51
  • I pasted the print here: [link](http://jsfiddle.net/7LSdu/).I didn't find that line. I found only $this->response->body($this->view);. I don't know if it is this way cause im using kostache. Just to review, in the other pages that bring that data has the structure a pasted in my question. Hope it's help!!! – JGSilva Mar 26 '12 at 16:33
  • I think you need to look at the [Kostache pages](https://github.com/zombor/KOstache) to figure out their syntax...I don't use it and it doesn't quite make sense to me. A simple way of making sure your config is working is to do $this->response->body($this->config['arrayName']) or just print_r($this->config) and make sure the values exist. It seems you're using config for entries...it actually would make more sense to store that information in a database of some sort instead. – gspatel Mar 26 '12 at 17:22
  • I know it's not the right way. A database it's the right answer for that. Anyway I'm glad with your help. Tks. I will keep trying waiting for a database guy here where I work. If I get to something I will post here! – JGSilva Mar 26 '12 at 19:08