$replaceContent = new jquery('replace') and =& get_instance() confusion!!! - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: $replaceContent = new jquery('replace') and =& get_instance() confusion!!! (/showthread.php?tid=16084) |
$replaceContent = new jquery('replace') and =& get_instance() confusion!!! - El Forum - 02-24-2009 [eluser]thinkigniter[/eluser] I need some help with a helper I'm writing. It's called taconite or taco for short. It's main function is to create an xml file. It allows you to do JQUERY commands from within PHP. E.G. Code: $replaceContent = new taconite('replace'); or Code: $slideDown = new taconite('slideDown'); This will allow you to replace the content of your div tag with the id of my_div with the new content. E.G. Code: <div id="my_div">Something to start with</div> Now I won't go on about how this happens until the Docs are complete but I do have a question that I can't find an answer for. It is… In my wrapper class for the jquery function "replace" I need to write back to the "parent_class". I do this with… Code: "$object =& get_instance(); $object->store['xmlString'] = 'This is my new content'; " The Question: Now does this mean that my class now contains a duplicate of the CI_BASE class in my class or is it just able to refer back to it? $replaceContent = new jquery('replace') and =& get_instance() confusion!!! - El Forum - 02-24-2009 [eluser]xwero[/eluser] If the main function is to create an xml file why do you need the CI object? Can't you just write to the xml file directly? Code: $slideDown = new taconite('slideDown'); Code: <slideDown select="#example4" value="100" /> If you want to store the tags you better have one object where you add all the tags for the xml file to. Code: $this->tactonite->open_tag('slideDown'); $replaceContent = new jquery('replace') and =& get_instance() confusion!!! - El Forum - 02-24-2009 [eluser]thinkigniter[/eluser] Thanks for answering xwero. This is what I have so far... Code: class Taconite{ Now what i'm worried about is have multiple copies of "taconite" class with "get_instance()" refering back to the parent class where the content of the "xmlString" array is read and displayed as an xml file. Are all the array's and objects from the CI_BASE object included in my "taconite" class or are they only refering back to them? $replaceContent = new jquery('replace') and =& get_instance() confusion!!! - El Forum - 02-24-2009 [eluser]xwero[/eluser] There is no reason why the class needs to depend on CI to store the generated tags. My taconite class Code: class Taconite $replaceContent = new jquery('replace') and =& get_instance() confusion!!! - El Forum - 02-24-2009 [eluser]thinkigniter[/eluser] Great example. I love this Code: function set($command, $args = NULL) Thanks for the work but the format of the xml must be like this... Code: <taconite> As you can see multiple "taconite objects" are needed to generate the correct formats all writing back to one source in the parent controller $replaceContent = new jquery('replace') and =& get_instance() confusion!!! - El Forum - 02-24-2009 [eluser]xwero[/eluser] You shouldn't look at the tags as objects, this is one of the reasons the library you CI-ed has so much negative responses. It's too much abstraction for a tag that can be generated using a function. The tags are just a bunch of strings with the same format. you can write one function to create all xml style tags you need. Code: function create_tag($name,$attributes='',$content='',$self_closing = false) And you can use this function to create functions that are easier for the developers to use. But back to your helper now. For the CI-ed class it makes sense to make different objects because they are independent. But your helpers functionality is to create an xml file which means the tags are related. An example how the creation of your taconite xml file would look with my library Code: $this->taconite->open_tag('css')->set('p.important', array('red','blue'))->close_tag('css'); Code: $this->taconite->add_tag('slideUp','div#features ul','fast'); $replaceContent = new jquery('replace') and =& get_instance() confusion!!! - El Forum - 02-24-2009 [eluser]thinkigniter[/eluser] Thanks XWERO, I understand, I like the way you've done this do you mind if I incorporate some of the idea's you've shown here into my final scripts. Of course, I won't just copy and paste but rework the ideas. Thanks again. |