Welcome Guest, Not a member yet? Register   Sign In
Database text and PHP code
#1

I'm sure this is an old chestnut but I am building a simple CMS to hold page text. The problem is that the pages currently use CI helper functions eg base_url() for image paths and safe_mailto() for mail links, . When the mysql db spits out the page of text, the php code obviously appears as plain text so that's not going to work. I can go the route of not using these helper functions but then I lose some CI functionality and create more work.

I've explored echoing the db text within eval() but it includes html tags and they cause PHP to throw an error.

As this must be an old and well-known problem, I wonder if there is an equally well-known standard workaround. I have been unable to find anything with Google so I hope some forum member can help me - even if only to say 'stop wasting time, it's impossible'
Reply
#2

You could use the template parser ... https://www.codeigniter.com/user_guide/l...rse_string

Retrieve the "page" from the database, and run the result through the template parser to get the desired HTML.
Reply
#3

Brilliant - thanks so much. I've never used the template parser and I'd forgotten it existed. That is a solution!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB