I get this Notice
:
Notice: Undefined offset: 1 in custom_context_section_condition->_get_url_section() (line 110 of modules/custom/custom_context/plugins/custom_context_section_condition.inc).
**
* Get section by url
*/
function _get_url_section() {
// get the correct URL
$path = $_GET['q'];
if (arg(0) == 'node' && is_numeric(arg(1))) {
$path = drupal_get_path_alias($_GET['q']);
}
$path = explode('/', $path);
// Remove reserved part from path when defined as constant (see custom_context.module)
if (in_array(arg(0), unserialize(URL_PATH_PART))) {
array_shift($path);
}
// Remove reserved string from path when defined as constant (see custom_context.module)
else if ($new_path = _custom_context_strpos_replace_arr($_GET['q'], unserialize(URL_PATH_STRING))) {
$path = explode('/', $new_path);
}
// Get section by path
$value = str_replace('-', ' ', $path[1]);
$terms = taxonomy_get_term_by_name($value);
// make sure we are getting the right section under the correct city
// check if city context exist
$city = NULL;
$contexts = context_active_contexts();
if ($contexts = context_active_contexts()) {
foreach ($contexts as $key => $context) {
if ($key == 'city') {
$city = $context->conditions['custom_city']['city']['term'];
break;
}
}
}
else {
$city_context = new custom_context_city_condition(this, array());
$cities = $city_context->_get_city($node);
$city = array_shift($cities);
}
// check parent tid here
foreach ($terms as $key => $term) {
$parents = taxonomy_get_parents($term->tid);
$parent = array_shift($parents);
if ($city->tid != $parent->tid) {
unset($terms[$key]);
}
}
return $terms;
}
This part:
if ($city->tid != $parent->tid) {
unset($terms[$key]);
}
Also says: Notice: Trying to get property of non-object
Any idea whats wrong in my code?
Array ( [0] => node )
, would that be a problem?