Welcome Guest, Not a member yet? Register   Sign In
Parser library, variable scope..

Today I realize that my view always went wrong because I had two variable: first is scalar, the last is array.

the last variable contains variable with same name with the first variable.

for example:
In controller:
//...... controller

$last_industry = '20';

$industries = $this->industriesmodel->findAll();
// will contain array of industries, each element contains:
// industry_id, industry_name
$data['industry_id'] = $last_industry;
$data['industries']  = $industries;

$this->parser->parse('myview', $data);

In view:
      <td>Last Industry ID : {industry_id}</td>
      <td>Select other ID:
          <select name="industry_id">
                <option value="{industry_id}">{industry_name}</option>

Lets say, the value of the first 'industry_id' (after the word "Industry ID:") is '20',
then the combo box (select box)'s industry_id will be replaced with '20' too..

anyone ever face with this problem?
just share my thought, the problem was solved by changing the combobox's industry_id name into something else like '_industry_id' to differs with the first 'industry_id',

ps. sorry my english.


Hi man!

It's because pseudo-variable replacing is before cycles. I've made my own Template Parser, whitch is correct + providing more functions.

Take a look:



Theme © iAndrew 2016 - Forum software by © MyBB