<?php namespace App\Controllers;

class Page extends FrontController
{	
	public function index($page_url){
		$data['language_code'] = $this->get_requested_lang_code();
		$data['rec'] = $this->get_detail($page_url,$data['language_code']);
		/*echo '<pre>';
		echo $page_url;
		print_r($data);
		exit();*/
		$data['meta_data']['title'] = $data['rec']['meta_title'];
		$data['meta_data']['description'] = $data['rec']['meta_description'];
		$data['meta_data']['keywords'] = $data['rec']['meta_keywords'];
		
		echo $this->view_inner_template('page',$data);
	}
	 
	private function get_detail($page_url,$lang_code){
		$builder = $this->cmObj->get_table_builder('page AS p');
		$query = $builder->join('page_ln AS pl',"p.page_id=pl.page_id AND pl.language_code='".$lang_code."'",'left')
			->select('p.banner_image, pl.*')
			->where('p.page_url',$page_url)
			->where('p.status','Active')
			->where('p.is_deleted','No')
			->get();
		$rec = $query->getRowArray();
		return $rec;
	}
}