Jump to content
Sign in to follow this  
svallory

Where does the platform determine the current page template?

Recommended Posts

svallory

Hey guys, I'm trying too hook up PodsCMS to PageLines. Only thing missing is I can't get the Platform to use the page template I've seleted on the Pods page configuration. Can you tell me where the platform chooses which page template to render so I don't have to read the entire code? thanks!

Share this post


Link to post
Share on other sites
svallory

Got it! But I had to modify the Platform code, which isn't good. I'll post a feature request for this new filters. Anyway, if you want to hack in, this is how... 1. Replace the methods `PageLinesTemplate::set_main_type()` and `PageLinesTemplate::get_page_template()` in platform/includes/class.template.php with this code:

		function set_main_type(){
	
			if(is_home() || is_tag() || is_search() || is_archive() || is_category()){
				$value = 'posts';
			}elseif(is_single()){
				$value = 'single';
			}elseif(is_404()){
				$value = '404';
			}
			else {
				$value = 'default';
			}
	
			return apply_filters('set_main_type', $value);
		}
		function get_page_template(){
			global $post;
	
			if(is_404()){ return '404';}
			elseif(is_home() || is_tag() || is_search() || is_archive() || is_category()){ return 'posts';}
			elseif(is_single()){return 'single';}
			elseif(is_page_template()){
				/*
					Strip the page. and .php from page.[template-name].php
				*/
				$page_filename = str_replace('.php', '', get_post_meta($post->ID,'_wp_page_template',true));
				$template_name = str_replace('page.', '', $page_filename);
				$value = $template_name;
			}
			else{
				$value = 'default';
			}
	
			return apply_filters('get_page_template', $value);
		}
	
2. In platform/functions.php file add the following code: Before the require to `core.init.php`
	add_filter('set_main_type', 'filter_main_type');
	add_filter('get_page_template', 'filter_page_template');
	
	function filter_main_type($val) {
		if(is_pod_page())
				return 'pods';
	
		return $val;
	}
	
	function filter_page_template($val) {
		if(is_pod_page())
				return 'pods_page';
	
		return $val;
	}
	

Share this post


Link to post
Share on other sites
svallory

Sorry for the messy code, I wish we had a preview :/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×