Undefined property error in custom module
Most likely  $router_item['page_arguments'][$key]->type is undefined.

Try with :

if (is_object($argument) &amp;&amp; isset($router_item['page_arguments'][$key]-&gt;type) &amp;&amp; in_array($router_item['page_arguments'][$key]-&gt;type, array('article', 'page'))) {


Same thing for that foreach loop. Just add an if isset() before that loop and you'll be ok.

if (isset($data['tabs'][0]['output']) ) {
    foreach ($data['tabs'][0]['output'] as $key =&gt; $value) {
        ....