Archived

This topic is now archived and is closed to further replies.

  • 0

Resolved how to create a custom page template, using custom field values

Question

Posted · Report post

I'm converting a non-PL site to PL and one of the page templates (tour.php) is like this:

if URL has "?v=unbranded" in it, display custom fields 1-20...

get meta field 1

(link url = get meta field 2) get meta field 3 (close link tag)

get meta field 4

...

20

if URL doesn't have "?v=unbranded" in the browser address bar, display custom fields 21-35

get meta field 21

(link url = get meta field 22) get meta field 23 (close link tag)

get meta field 24

...

35

How can I create a page template for PageLines like this, even if it has to be:

if ?v=unbranded, display

CUSTOM SECTION UNBRANDED TOUR code

else

CUSTOM SECTION BRANDED TOUR code

or something like that.

Anything at all, please provide a solution.

Thank you very much.

Share this post


Link to post
Share on other sites

25 answers to this question

Posted · Report post

Cliff, why do you want multiple headers, if you explain why, we able to help with a solution.

Share this post


Link to post
Share on other sites

Posted · Report post

Cliff, instead of creating templates, why not use a simple wordpress action to insert your code where needed, and use the wordpress is_page() condition.

Share this post


Link to post
Share on other sites

Posted · Report post

I want the header section to be like the template section for drag-and-drop, plus some control over what goes in the < head > section, like the new Thesis 2.0 does.

Usage:

For a custom post type, I'm displaying real estate tours and I have a _GET that says if url variable has ?v=unbranded then display this "view" else display the branded "view" (due to real estate MLS systems requiring unbranded versions and I don't want to have to create 2 pages/templates for the same information (e.g. the address and MLS number and photos don't change). The "views" I mentioned are essentially 2 page templates within 1 (not a PL theme, trying to convert to it).

For the branded version, I have social sharing links, facebook og integration, and a navigation.

For the unbranded version, social sharing links, navigation, etc. aren't allowed.

Here's an example of my current theme's display of each:

branded: http://tourkick.com/tours/20110715-2136-east-22nd-place-tulsa-ok-74114-2/

unbranded: http://tourkick.com/tours/20110715-2136-east-22nd-place-tulsa-ok-74114-2/?v=unbranded

(FYI: currently that's just a single page, not a CPT page)

It's all custom fields and it's not totally done, but hopefully that gives you the understanding of what I want.

I've been messing around with a custom section this morning and I suppose I could do all that conditional stuff within it and just drag it to the "real estate tour" custom page template but that still doesn't get my < head > stuff -- except maybe I can remove_action or do some other stuff in a custom section to remove my Crackbar and Branding -- dunno -- want some guidance though.

Thanks, Simon.

Share this post


Link to post
Share on other sites

Posted · Report post

In case it helps anyone else, here's my final code to turn off fixed crackbar for all single post displays for a CPT:

functions.php


// http://wordpress.stackexchange.com/questions/6731/if-is-custom-post-type

// http://codex.wordpress.org/Conditional_Tags#A_Single_Page.2C_Single_Post_or_Attachment

// http://www.pagelines.com/forum/topic/22299-how-to-create-a-custom-page-template-using-custom-field-values/#entry130346

/*

hide crackbar if CPT is specified in the array

fyi: still shows the padding because of

body.crackbar_fixed .page-canvas {

padding-top: 50px;

}

but can override that in custom section css (or elsewhere)

*/

add_action('template_redirect','navbar_checker' );

function navbar_checker() {

global $wp_filter;


if (is_singular( array( 'propertytour', 'book' ) )) {

 if ( isset( $wp_filter['pagelines_before_page'][10]))

  unset( $wp_filter['pagelines_before_page'] );

   }

}

Thank you for your help once again.

Share this post


Link to post
Share on other sites

Posted · Report post

Custom section would be the best plan to insert custom code, or a plugin could do it too with is_page, also to hide crackbar etc, just go to that pages options and hide them

Share this post


Link to post
Share on other sites

Posted · Report post

Topics merged...

Share this post


Link to post
Share on other sites

Posted · Report post

not the fixed crackbar though - that's not drag-and-drop

or am I missing something?

Share this post


Link to post
Share on other sites

Posted · Report post

Oh right yea, well in that case you can actually filter the main options, and turn off the navbar on that page

Share this post


Link to post
Share on other sites

Posted · Report post

how do i filter the main options?

how do i assign all of a specified CPT to a single page template?

Share this post


Link to post
Share on other sites

Posted · Report post

custom post types should have their own template area in drag and drop, they dont need a wordpress template.

Share this post


Link to post
Share on other sites

Posted · Report post


add_action('template_redirect','navbar_checker' );
function navbar_checker() {
global $wp_filter;

if ( is_page( 2 ) ) {
if ( isset( $wp_filter['pagelines_before_page'][10]))
unset( $wp_filter['pagelines_before_page'] );

}
}
[/CODE]

Add to customize plugin, and change the page number.

Share this post


Link to post
Share on other sites

Posted · Report post

That's smart. Way to go. :-)

So how do I filter the main options?

Share this post


Link to post
Share on other sites

Posted · Report post

Oh right yea, well in that case you can actually filter the main options, and turn off the navbar on that page

How do I do this? Thanks.

Share this post


Link to post
Share on other sites

Posted · Report post

Are there any references for how to create multiple headers for a site?

A "regular" WP theme would just have header.php, single.php, and footer.php --> and also header-whatever.php, single-whatever.php, and footer-whatever.php.

How do I do this with PageLines?

Thank you.

Share this post


Link to post
Share on other sites

Posted · Report post

if i am using a theme which will not allow me to create links to "fixed" boxes - I was told I could supply a page id to override the template.  Where can I get information on how to do this and does it automatically mean I need to know code?

Share this post


Link to post
Share on other sites

Posted · Report post

Hi Scanlondesign, please start a new post for your question.

Share this post


Link to post
Share on other sites

Posted · Report post

tyvm, @simon. It worked. Only thing is that it now looks like there's something missing at the top due to extra padding. Although that may be due to using a fixed nav. I'm sure I can fix that another way when I get to finalizing it. tyvm.

Share this post


Link to post
Share on other sites

Posted · Report post

The topic was marked as resolved.

Share this post


Link to post
Share on other sites

Posted · Report post

The topic was marked as resolved.

Share this post


Link to post
Share on other sites

Posted · Report post

You're right. It's a broken link, which I've addressed to the developers.

You can do this with Sections and apply sections to specific parts of your site. Admittedly, it's not the easiest thing to do. See http://www.pagelines.com/wiki

Share this post


Link to post
Share on other sites

Posted · Report post

Where in the wiki does it address this situation? I'd love to see a link. Thank you very much.

Share this post


Link to post
Share on other sites

Posted · Report post

thanks for the references.

is there a way to conditionally call a section / templatepart?

for example:

-create section1

-create section2

-create pagetemplateX

-within pagetemplateX say "if this, then section1; else, section 2"

I think not because the page.name.php file is just for protocol, not including custom functionality.

So maybe this:

-section1

-section2

-section3 = if this, section1; else, section2.

I hope my q makes sense.

Thanks.

Share this post


Link to post
Share on other sites

Posted · Report post

Hey there,

Creating another page template is as easy as adding this code to a new php file and placing it in the root of the child theme:


<?php

/*

Template Name: YOUR TEMPLATE NAME

*/

setup_pagelines_template();

The only caveat being that the file name needs to follow this naming scheme: page.somename.php. I'd recommend not using any dashes or underscores in the "somename" portion of it, as it's given me trouble before.

From there, the template will be available to customize within the drag & drop area of the framework.

Regarding the part about conditionally integrating your content with meta data, the easiest thing to do would be to create a custom section to handle this.

A section can be very simple and has very few requirements. You can strip it down to almost nothing and just use the section_template method to write your whole template for that content if you wanted. The benefit of a section is that it also provides other methods for conditionally enqueuing scripts and other stuff just when the section is active on that page. Again, check out the sample PullQuote section in the Developer Tookit found here.

Hope that helps!

Share this post


Link to post
Share on other sites