CI Parser Mod - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: CI Parser Mod (/showthread.php?tid=25325) |
CI Parser Mod - El Forum - 12-08-2009 [eluser]CodyPChristian[/eluser] Been awhile since I've been around the forums, actually its been almost 2 years!! Either way I still develop with CI daily. While developing the other day I came across a little problem while using one of the CI libs. I come across little things like this alot but I never post them Let me explain first the use of this mod, then I will share the code for it. In my pacific case I needed a way to pass a template from a table to the parser class along-side the array of parsing variables for the parser to replace with. I needed it to allow that action as well as to return to a variable. The latter you can do by default via the 3rd param, however it expects that you pass in a view file and not a variable containing the data. This way I could then pass the data onto another function. Maybe there is another way to do this but this worked in my case. Example Usage: Code: $TemplateParams = //Array of template parsing variables to replace the {vars} within $EmailTemplate Parser.php Mod /system/libraries/parser.php Code: #/system/libraries/parser.php I modified the function by adding the 4th param $bypass and adding the two !$bypass if statements. To use the previous function just replace your parser() function in your parser.php file. I do not know if adding my 'mod comment' is allowed by Ellis, however I add it to all files I modify to keep track of when I modified them. I hope the code above is self-explanatory but if you have any questions let me know. In basic form it allows me to pass data in from a $variable instead of a view and return to a $variable. CI Parser Mod - El Forum - 12-09-2009 [eluser]Phil Sturgeon[/eluser] Good to see you post again dude, it's been a while! Why not just extend the Parser class instead of modifying the core? application/libraries/MY_Parser.php Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed.'); CI Parser Mod - El Forum - 12-09-2009 [eluser]CodyPChristian[/eluser] Phil, you have a point, I could have done it that way too, just wasn't thinking I guess Thanks. |