The item array gets null from here:
hItems.php:
/**
* Gets current item array from view
*
* @return array $item, or null if not exist
*/
function osc_item() {
if(View::newInstance()->_exists('item')) {
$item = View::newInstance()->_get('item');
} else {
$item = null;
}
return($item);
}
The solution is:
/**
* Create item url from item data without exported to view.
*
* @since 3.3
* @param array $item
* @param string $locale
* @return string
*/
function osc_item_url_from_item($item, $locale = '')
{
if ( osc_rewrite_enabled() ) {
$url = osc_get_preference('rewrite_item_url');
if( preg_match('|{CATEGORIES}|', $url) ) {
$sanitized_categories = array();
487: if( isset($item["fk_i_category_id"]) ) { //new line
$cat = Category::newInstance()->hierarchy($item['fk_i_category_id']);
for ($i = (count($cat)); $i > 0; $i--) {
$sanitized_categories[] = $cat[$i - 1]['s_slug'];
}
$url = str_replace('{CATEGORIES}', implode("/", $sanitized_categories), $url);
} // new line
}
495 if( isset($item["pk_i_id"]) ) { $url = str_replace('{ITEM_ID}', osc_sanitizeString($item['pk_i_id']), $url); }
496 if( isset($item["s_city"]) ) { $url = str_replace('{ITEM_CITY}', osc_sanitizeString($item['s_city']), $url); }
497 if( isset($item["s_title"]) ) { $url = str_replace('{ITEM_TITLE}', osc_sanitizeString($item['s_title']), $url); }
$url = str_replace('?', '', $url);
if($locale!='') {
$path = osc_base_url().$locale."/".$url;
} else {
$path = osc_base_url().$url;
}
} else {
$path = osc_item_url_ns($item['pk_i_id'], $locale);
}
return $path;
}