<?php defined('BASEPATH') OR exit('No direct script access allowed');

if ( ! function_exists('breadcrumbs'))
{
	function breadcrumbs()
	{
		$ci = & get_instance();

		$current_url = str_replace(base_url().'index.php/','',current_url());
		$breadcrumbs = array();

		$current_page = $ci->db->get_where('page',array('page_url'=>$current_url,'is_page_section'=>'1'))->row();
		if( $current_page != NULL ) {
			$breadcrumbs['data'] = array();
			$breadcrumbs['active'] = $current_page->page_ID;
			array_unshift($breadcrumbs['data'], $current_page);

			while($current_page->parent_page!==''){
				$current_page = $ci->db->get_where('page',array('page_ID'=>$current_page->parent_page))->row();
				array_unshift($breadcrumbs['data'], $current_page);
			}
		}

		return $breadcrumbs;
	}
}