Is it possible to store mixed html and php content in a db table and have it rendered in views? If I have the following in the table
<?php echo $html->link('Cool product 1', array('controller' => 'products', 'action' => 'view', 1), array('target' => '_blank')); ?>
this is what get's rendered:
link('Cool product 1', array('controller' => 'products', 'acti开发者_运维知识库on' => 'view', 1), array('target' => '_blank')); ?>
I'd like the link , not the code. How can I achieve that?
UPDATE
It's for a multi-lingual site. I'd like to store the different static pages, in different languages, in a table, instead of having them in the page view folder.
I'd like to keep my helper code, so that I can create and test my pages locally before putting them online, and not having to worry about urls.
I'd like to put them in a table as it would simplify my code. I could link them to my site hierarchy, that is in a table.
Either store the link as HTML in your database or you could try using Eval to run the code.
Update: To get around the problem with the opening PHP tag you can try using eval like this: eval('?>' . $content);
But I think it's a bad idea to store plan PHP code into your database. Maybe explaining what you would like to achieve and why you are using this approach would help getting better answers. Someone said "if eval is the answer, the question was wrong". You should consider to rethink what you are trying to achieve.
精彩评论