Created
August 13, 2012 13:10
-
-
Save jamiefdhurst/3340581 to your computer and use it in GitHub Desktop.
Get parent title in PyroCMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('BASEPATH') OR exit('No direct script access allowed'); | |
class Plugin_Page_Parent extends Plugin | |
{ | |
public function title() | |
{ | |
// Use the URI to get the previous page name, and set the title accordingly | |
$uri_parts = explode('/', $this->uri->uri_string()); | |
if (count($uri_parts) > 1) | |
{ | |
$parent_slug = $uri_parts[count($uri_parts) - 2]; | |
$my_slug = end($uri_parts); | |
// Find the parent page and get its title | |
$this->load->model('pages/page_m'); | |
$parent = $this->page_m->get_by('slug', $parent_slug); | |
$me = $this->page_m->get_by('slug', $my_slug); | |
$this->template->title($parent->title, $me->title); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment