Skip to content

Instantly share code, notes, and snippets.

@jamiefdhurst
Created August 13, 2012 13:10
Show Gist options
  • Save jamiefdhurst/3340581 to your computer and use it in GitHub Desktop.
Save jamiefdhurst/3340581 to your computer and use it in GitHub Desktop.
Get parent title in PyroCMS
<?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