Jump to content


Photo
- - - - -
Resolved

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



  • Please log in to reply
25 replies to this topic

#1 CliffordP

CliffordP

    Advocate

  • Members


  • 474 posts
  • LocationOklahoma
  • Country: Country Flag

Posted 01 October 2012 - 05:40 PM

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.

#2 Evan Mattson

Evan Mattson

    Super Member

  • Members

  • 231 posts
  • LocationAnn Arbor, MI
  • Framework Version:latest stable & beta releases
  • Country: Country Flag

Posted 01 October 2012 - 06:59 PM

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:

Please Login or Register to see this Hidden Content


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

Please Login or Register to see this Hidden Content

.

Hope that helps!

#3 CliffordP

CliffordP

    Advocate

  • Members


  • 474 posts
  • LocationOklahoma
  • Country: Country Flag

Posted 03 October 2012 - 07:32 PM

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.

#4 CliffordP

CliffordP

    Advocate

  • Members


  • 474 posts
  • LocationOklahoma
  • Country: Country Flag

Posted 04 October 2012 - 01:02 AM

I was doing some research and found

Please Login or Register to see this Hidden Content

but it links to a "template map" which is a dead link.

It seems pagelines_template_area is the PL version of get_template_part. Am I mistaken?

#5 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 04 October 2012 - 01:16 AM

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

Please Login or Register to see this Hidden Content



#6 CliffordP

CliffordP

    Advocate

  • Members


  • 474 posts
  • LocationOklahoma
  • Country: Country Flag

Posted 04 October 2012 - 03:07 AM

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

#7 CliffordP

CliffordP

    Advocate

  • Members


  • 474 posts
  • LocationOklahoma
  • Country: Country Flag

Posted 04 October 2012 - 03:11 AM

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.

#8 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 04 October 2012 - 12:05 PM

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

#9 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 04 October 2012 - 12:07 PM

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.

#10 CliffordP

CliffordP

    Advocate

  • Members


  • 474 posts
  • LocationOklahoma
  • Country: Country Flag

Posted 04 October 2012 - 12:17 PM

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:

Please Login or Register to see this Hidden Content


unbranded:

Please Login or Register to see this Hidden Content


(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.

#11 CliffordP

CliffordP

    Advocate

  • Members


  • 474 posts
  • LocationOklahoma
  • Country: Country Flag

Posted 04 October 2012 - 12:19 PM

Sorry these 2 forum posts (

Please Login or Register to see this Hidden Content

) are blending together... Feel free to reply to each individually or to combine them by replying to just one of them and turning off comments on the other.
Thanks.

#12 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 04 October 2012 - 12:22 PM

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

#13 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 04 October 2012 - 12:26 PM

Topics merged...

#14 CliffordP

CliffordP

    Advocate

  • Members


  • 474 posts
  • LocationOklahoma
  • Country: Country Flag

Posted 04 October 2012 - 12:26 PM

not the fixed crackbar though - that's not drag-and-drop
or am I missing something?

#15 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 04 October 2012 - 12:28 PM

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

#16 CliffordP

CliffordP

    Advocate

  • Members


  • 474 posts
  • LocationOklahoma
  • Country: Country Flag

Posted 04 October 2012 - 12:41 PM

how do i filter the main options?

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

#17 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 04 October 2012 - 12:45 PM

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

#18 CliffordP

CliffordP

    Advocate

  • Members


  • 474 posts
  • LocationOklahoma
  • Country: Country Flag

Posted 04 October 2012 - 01:16 PM

That's smart. Way to go. :-)
So how do I filter the main options?

#19 CliffordP

CliffordP

    Advocate

  • Members


  • 474 posts
  • LocationOklahoma
  • Country: Country Flag

Posted 04 October 2012 - 03:46 PM

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.

#20 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 05 October 2012 - 05:47 PM

Please Login or Register to see this Hidden Content


Add to customize plugin, and change the page number.





Also tagged with one or more of these keywords: Resolved