• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Database text and PHP code

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'

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.

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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

Users browsing this thread:
1 Guest(s)

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.