Cannot Access Global Variable in Loop |
Hello.
Im passed an array and some global variables array to view file. Code: $website_lang_array = array ( if i use this variable a outside of lop such as Code: {LANG15} this is working good. But when i try to access in loop such as Code: {content} This is not working. i think its search {LANG15} in content array. i must acces {LANG15} in loop. but how? Thanks inadvance.
You are right: it's trying to load LANG15 from "content" array rather than main array. I don't think build-in Parser library has a solution for you. But you can use another parser library (I use Mustache myself https://github.com/bobthecow/mustache.php), but it will require additional work of setting it up.
P.S. I can send you link to my drop-in version of the library that requires no changes in your code to use it (e.g. $this->parser->parse). (02-09-2016, 03:22 PM)siburny Wrote: You are right: it's trying to load LANG15 from "content" array rather than main array. I don't think build-in Parser library has a solution for you. But you can use another parser library (I use Mustache myself https://github.com/bobthecow/mustache.php), but it will require additional work of setting it up. thanks for reply. so, all other users using another parser libraries? this is weird. in a looop i can't access a variable :S this is enough for leave codeignitier.
You can use variable in a loop. You have to put it inside a specific sub-array ("content" in your case). Most people tend to pass to view/parser variables that are needed for that particular template rather then throw everything at it and let template decide if it needs it.
What I suggest you do is use language helper: lang - https://www.codeigniter.com/userguide3/h...elper.html
Then you just load a language file in CI and you don't need to pass anything to a view or parser in this case. |
Welcome Guest, Not a member yet? Register Sign In |