Welcome Guest, Not a member yet? Register   Sign In
Extended CI Parser
#1

[eluser]Rolly1971[/eluser]
I did a few searches through the forum and wiki and could not find anything like this.

I was in need of a way to parser CI 'template tags' from content stored in a database table, IE: {tagname}. So Not finding anything that matched what i was looking for i cloned one of the functions from the CI Parser and adjusted it to accept a string instead of requiring a path to a file.

If something like this is posted here already and i just missed or overlooked it, my apologies.

Anyway, here it is.
the MY_Parser.php file is attached, save this file in one of the following locations depending on the version of CI you are using:

for CI 1.7.2: ./application/libraries/MY_Parser.php
for CI 2.0 : ./application/core/MY_Parser.php

usage is exactly the same as using the CI Parser class, except you call the parse_db_string() function instead of parse(). IE:
Code:
$this->load->libarary('parser');

$content = $this->parser->parse_db_string('My page content, parsed by a {tag}', array('tag' => '<b>extended CI Parser Class</b>', TRUE);

like i mentioned i built this to parser tags typed into content stored in a database, so to use this in that manner, retrieve your database stored content, and pass it into this function, as if you were using the CI parser. But instead of a path to a file, you are passing in the content from the database instead. the output is identical to the ci parser function parse(), third parameter: TRUE to return a string, FALSE to output directly to browser.

Hopefully this will help someone out, or at least be useful to someone. Any questions, just post em and i will answer best i can.


Messages In This Thread
Extended CI Parser - by El Forum - 09-20-2010, 06:55 PM
Extended CI Parser - by El Forum - 10-01-2010, 01:54 PM
Extended CI Parser - by El Forum - 10-02-2010, 01:49 PM
Extended CI Parser - by El Forum - 11-13-2010, 09:43 PM
Extended CI Parser - by El Forum - 11-13-2010, 10:12 PM
Extended CI Parser - by El Forum - 11-13-2010, 10:35 PM
Extended CI Parser - by El Forum - 11-13-2010, 11:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB