Check an empty component - Printable Version +- GetSimple Support Forum (http://get-simple.info/forums) +-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3) +--- Forum: Scripts & Components (http://get-simple.info/forums/forumdisplay.php?fid=11) +--- Thread: Check an empty component (/showthread.php?tid=3102) |
Check an empty component - marcotls - 2012-04-22 Hi guys! I'm developing 3 new free responsive html5 themes for Get simple. I'll post them soon. By the way, here's my question. I need to check if a given component is empty or not. If it is not empty, the template shows some code and the component itself, if it is empy, it won't. I've tried using Code: <?php but the function does not work (it prints out the content, since the function get_component doesn't return a value, but prints it out directly). Any ideas please? Thank you guys! Marco Check an empty component - Carlos - 2012-04-25 Put this code in your theme (I suggest you create a functions.php file and put it there): Code: <?php Then use it in your template file(s) like this: Code: <?php if (component_exists('mycomponent')) { ?> That would be for enclosing a component, only if it exists, between some html code. If you just want to display alternative content when the component does not exist, it could be like: Code: <?php |