public function get_link() { // Get the link $id_page = $this->input->post('id_page'); $page = $this->page_model->get_by_id($id_page); $link_type = $page['link_type']; $title = NULL; $breadcrumb = ''; if (in_array($link_type, array('page', 'article'))) { if ($link_type === 'article') { $link_rel = explode('.', $page['link_id']); $link_id = isset($link_rel[1]) ? $link_rel[1] : NULL; $breadcrumb = $this->page_model->get_breadcrumb_string($link_rel[0]); } else { $link_id = $page['link_id']; $breadcrumb = $this->page_model->get_breadcrumb_string($page['link_id']); } $link = $this->{$link_type . '_model'}->get_by_id($link_id, Settings::get_lang('default')); if (!empty($link)) { $title = !empty($link['title']) ? $link['title'] : $link['name']; if ($link_type === 'article') { $breadcrumb .= ' > ' . $title; } } else { $this->_remove_link($id_page); } } else { $title = $page['link']; } $this->template = array('parent' => 'page'); if (!is_null($title)) { $this->template = array('parent' => 'page', 'rel' => $id_page, 'link_id' => $page['link_id'], 'link_type' => $page['link_type'], 'link' => $title, 'breadcrumb' => $breadcrumb); } $this->output('shared/link'); }
public function get_link() { // Get the article in the context of the page $id_page = $this->input->post('id_page'); $id_article = $this->input->post('id_article'); // Get the receiver's context $context = $this->article_model->get_context($id_article, $id_page); $this->template = array('parent' => 'article'); if (!empty($context['link'])) { $title = NULL; $breadcrumb = ''; // Prep the Link switch ($context['link_type']) { case 'page': $link = $this->page_model->get_by_id($context['link_id'], Settings::get_lang('default')); $breadcrumb = $this->page_model->get_breadcrumb_string($context['link_id']); // Correct missing link if (empty($link)) { $this->_remove_link($id_page, $id_article); break; } $title = !empty($link['title']) ? $link['title'] : $link['name']; break; case 'article': $link_rel = explode('.', $context['link_id']); $link = $this->article_model->get_by_id($link_rel[1], Settings::get_lang('default')); $breadcrumb = $this->page_model->get_breadcrumb_string($link_rel[0]); // Correct missing link if (empty($link)) { $this->_remove_link($id_page, $id_article); break; } $title = !empty($link['title']) ? $link['title'] : $link['name']; $breadcrumb .= ' > ' . $title; break; case 'external': $link_rel = ''; $title = $context['link']; break; } if (!is_null($title)) { $this->template = array('parent' => 'article', 'rel' => $id_page . '.' . $id_article, 'link_id' => $context['link_id'], 'link_type' => $context['link_type'], 'link' => $title, 'breadcrumb' => $breadcrumb); } } $this->output('shared/link'); }