How to resolve : “Undefined variable: crumb” error with openclassifieds

Recently on our website which uses openclassifieds scripts for classifieds, we started getting following errors,

 Undefined variable: crumb 

When we looked at other error logs, we see following errors along with the above primarily visible error in browser,

2018-01-31 10:00:26 — ERROR: ErrorException [ 8 ]: Undefined variable: content ~ APPPATH/common/views/alert_terms.php [ 9 ] in oc/kohana/system/classes/Kohana/Kohana/Exception.php:110
2018-01-31 10:00:26 — ERROR: ErrorException [ 8 ]: Undefined variable: data ~ DOCROOT/themes/reclassifieds3/views/header.php [ 36 ] in oc/kohana/system/classes/Kohana/Kohana/Exception.php:110
2018-01-31 10:00:26 — ERROR: ErrorException [ 8 ]: Undefined variable: crumb ~ APPPATH/common/views/breadcrumbs.php [ 7 ] in oc/kohana/system/classes/Kohana/Kohana/Exception.php:110
2018-01-31 10:00:31 — ERROR: Kohana_Exception [ 0 ]: Required route parameter not passed: category ~ APPPATH/kohana/system/classes/Kohana/Route.php [ 572 ] in oc/kohana/system/classes/Kohana/Kohana/Exception.php:110

When we looked at the code, at oc/common/views/breadcrumbs.php its as below,

<?php defined('SYSPATH') or die('No direct script access.');?>
<? if (count($breadcrumbs) > 0) : ?>
        <ul class="breadcrumb">
        <? foreach ($breadcrumbs as $crumb) : ?>
                <? if ($crumb->get_url() !== NULL) :  ?>
                                <a title="<?=HTML::chars($crumb->get_title())?>" href="<?=$crumb->get_url()?>"><?=$crumb->get_title()?></a>
                <? else : ?>
                        <li class="active"><?=$crumb->get_title()?></li>
                <? endif; ?>
        <?endforeach; ?>
<? endif; ?>

So, from code its clear that, the error comes from the php code, like

 <li class="active"><?=$crumb->get_title()?></li> 

which shows its not able to identify crumb veriable, so for try, we removed “=” from before $crumb and the error went, but this is not the correct implementation, so when we further searched into internet, we found that


is required to have get the variable output. and this =$crumb is nothing but the short form of “echo $crumb” and its further detailed as like below,

short_open_tag boolean
Tells PHP whether the short form (<? ?>) of PHP's open tag should be allowed. If you want to use PHP in combination with XML, you can disable this option in order to use <?xml ?> inline. Otherwise, you can print it with PHP, for example: <?php echo '<?xml version="1.0"?>'; ?>. Also, if disabled, you must use the long form of the PHP open tag (<?php ?>).

This directive also affected the shorthand <?= before PHP 5.4.0, which is identical to <? echo. Use of this shortcut required short_open_tag to be on. Since PHP 5.4.0, <?= is always available.

Reference : php manual

hence to make sure


works well, we need to enable short_open_tag from php.ini so, the final solution is add following line into php.ini

 vim php.ini 

and make sure you have following line,

 short_open_tag = On 

If you are using shared hosting of some servers, the php.ini file will be present in /home/your_user_name/public_html/php.ini

Leave a Reply

Your email address will not be published. Required fields are marked *