Skip to content

Instantly share code, notes, and snippets.

@laoneo
Last active April 5, 2018 14:49
Show Gist options
  • Save laoneo/5f024c9d055cff7b79b01a641971574a to your computer and use it in GitHub Desktop.
Save laoneo/5f024c9d055cff7b79b01a641971574a to your computer and use it in GitHub Desktop.
public function build(&$query)
{
$this->updateEventParent($query);
return parent::build($query);
}
public function parse(&$segments)
{
$this->updateEventParent();
return parent::parse($segments);
}
private function updateEventParent($query = null)
{
$active = $this->menu->getActive();
$items = $this->menu->getItems('component', 'com_dpcalendar');
if ($active && $active->component == 'com_dpcalendar') {
array_unshift($items, $active);
}
foreach ($items as $item) {
if (!$item || empty($item->query['view']) || empty($this->views[$item->query['view']])) {
continue;
}
if ($query && !empty($query['Itemid']) && $query['Itemid'] != $item->id) {
continue;
}
$this->views['event']->setParent($this->views[$item->query['view']]);
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment