Newbie Object/Array View question |
[eluser]jpwdesigns[/eluser]
I've created a view for my header which controls the meta tags based on data the controler passes in as an object. It works fine. Code: <title> Code: $data['page']['meta_title'] = "PLEASE LOGIN |".$this->config->item('website_name', 'tank_auth'); This of course isn't working but I cant figure out how to do this correctly. I keep getting this error: Quote:A PHP Error was encountered Thoughts?
[eluser]rossmurphy[/eluser]
It looks like you are setting the meta data in an array, but then trying to access it through an object in the view. Do this instead in your view: Code: <title>
[eluser]jpwdesigns[/eluser]
HI, thanks for the reply. I am aware that I could change my view but i'm using this view for the majority of the site where i am passing in an object from a db. like this: Code: $data['page'] = $page->row();
[eluser]rossmurphy[/eluser]
Then in the controller, instead of setting an array, create the object you are trying to access.
[eluser]jpwdesigns[/eluser]
Right thats what I want to do. This is where my noob-ness comes in. I cant figure out how to do that. Can you show me an example? I need to know how to hard code a string into an object. Thanks in advance.
[eluser]rossmurphy[/eluser]
Have a read through this and you'll be on your way: http://www.php.net/manual/en/language.oop5.basic.php
[eluser]jpwdesigns[/eluser]
Yes i've read this several times plus countless other google searches. I just don't "get it" If you don't mind, it would really help to see an example for this specific situation. If you don't want to help with that, don't bother posting. I'm asking for help cause i'm thick skulled and i can't understand this. I'm new to objects.
[eluser]jpwdesigns[/eluser]
FINALLY, i figured it out. Its so totally ridiculously easy. Trying not to be frustrated with the "help" For any others new to objects this is how you create an object with a static hard coded string. Code: $data['page']->meta_title = 'some text here'; then in my view Code: <?=$page->meta_title?> ![]()
[eluser]cahva[/eluser]
Or use it like an array like rossmurphy said and change the database result to array: Code: $data['page'] = $page->row_array(); EDIT: aargh.. Too tired to answer questions. Ofcoz thats the better way ![]() |
Welcome Guest, Not a member yet? Register Sign In |