GetSimple Support Forum

Full Version: Best way to wrap "get_component()"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all,

In my theme i must to define if get_component('component-xyz') return null value.
I implement this function. 

PHP Code:
/**
 * This return get_component() function in a string
 *
 * @param string $id - ID of the component
 * @return string
 */
function return_get_component($id)
{
    
ob_start();
    
get_component($id);
    
$html ob_get_clean();

    return 
$html;


In this mode i can check if component return empty value (simply using "if" statement).

Do you resolve this problem in other way?
(2017-08-30, 01:11:42)tempUser Wrote: [ -> ]Do you resolve this problem in other way?

If your method works for you, then use it!

It is possible to test for existence of a component, for example see this wiki page, but your solution seems elegant.