CodeIgniter Forums
View Conundrum - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: View Conundrum (/showthread.php?tid=22280)



View Conundrum - El Forum - 09-03-2009

[eluser]georgerobbo[/eluser]
I have a standard view file for the <div id="content"></div> content of all my sub pages. But as you can imagine you'll want some custom elements within these content divs on some pages but not on others.

How can I approach this? Would it work to keep the code for the extra element in the view but use a PHP if isset statement so if a variable with the information was found the code would be used or if no variable was found the code would be ignored.

What is the best way of doing this?

Code:
&lt;?php
if(isset($account_profile))
{
echo "<div id="account_profile">&lt;?php foreach ($account_profile as $foo):?&gt;<p>&lt;?php echo $foo ?&gt;<p>&lt;?php endforeach; ?&gt;</div>"
}
else
{
}
?&gt;