Jump to content
TourKick (Clifford P)

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

Recommended Posts

TourKick (Clifford P)    1
TourKick (Clifford P)

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
evan    0
evan

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
TourKick (Clifford P)    1
TourKick (Clifford P)

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
Rob    547
Rob

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


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
TourKick (Clifford P)    1
TourKick (Clifford P)

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
TourKick (Clifford P)    1
TourKick (Clifford P)

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
Simon    247
Simon

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
Simon    247
Simon

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
TourKick (Clifford P)    1
TourKick (Clifford P)

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
Simon    247
Simon

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
Simon    247
Simon

Topics merged...

Share this post


Link to post
Share on other sites
TourKick (Clifford P)    1
TourKick (Clifford P)

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
Simon    247
Simon

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
TourKick (Clifford P)    1
TourKick (Clifford P)

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
Simon    247
Simon

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
TourKick (Clifford P)    1
TourKick (Clifford P)

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

So how do I filter the main options?

Share this post


Link to post
Share on other sites
TourKick (Clifford P)    1
TourKick (Clifford P)

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
Simon    247
Simon


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
TourKick (Clifford P)    1
TourKick (Clifford P)

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
Rob    547
Rob

The topic was marked as resolved.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
TourKick (Clifford P)    1
TourKick (Clifford P)

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
James B    436
James B

The topic was marked as resolved.


Kindly search the forum and read the documentation before posting. It will help you resolve many issues.

For CSS help be sure to check out W3Schools first and be sure to download FireBug for FireFox for troubleshooting.

James B

Share this post


Link to post
Share on other sites
scanlondesign    0
scanlondesign

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

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


  • Similar Content

    • janpeeters
      By janpeeters+
      Over the last month I had extensive communications with the developer of the (premium) Anything Boxes section (in Pagelines store) (Adam Munns) and the developer of the WP Polylang Multilingual plugin (Frederic Demarle).
       
      This was because the following problem occurred:
      Anything Boxes showed all posts of two languages (Dutch and English) on the respective static frontpages for each language. It should of course have filtered posts for Dutch language on the Dutch frontpage and English on the English frontpage.
       
      The solution to this problem was simple in the end. When duplicating a page for use in another language the settings for Anything Boxes were not copied to the new page and I should have set these settings manually again on the new page. I wasn't aware of this, but it makes sense. Because of this the pages didn't know how to differentiate between posts from different languages.
       
      The dev of Polylang told me that Polylang is currently smart enough to synchronize metas like Featured images and page templates but it does not work out of the box with metas created by plugins and themes but (according to Frederic) it is rather easy to add them in the list using the filter 'pll_copy_post_metas'.
      He mentions that he is not sure that these 'PageLines Meta Settings' are stored in post meta but that would make sense according to him. He asks if the Pagelines dev team will be interested to support this feature in the future.
       
      I'm also wondering if you will consider adding Polylang translation support for manually editable strings like the 'Read more…' strings in Pagelines Settings.
       
      Well that's of course up to you but I thought to let you know to be able to take this into consideration. I also post this for other users in case they experience the same kind of trouble and are looking for an answer.
       
      Best regards,
      Jan Peeters
    • bankrollbuilder
      By bankrollbuilder
      I used a custom hook to put a banner ad in my header. It works but its not in the right position. it is centered and above my logo and I would like to float it to the right of my logo in the header. heres the link: http://shaboopie.com/shaboopie-wp/free-logos-pg1/

      thanks.

      Dan B.
    • starlit
      By starlit
      Can one have two hero sections on one page?

      I want a landing page which leads/advertises two subpages.

      Or is there another option?

      Please help.

      THANK YOU
    • hutruk
      By hutruk
      Hi!

      I am using the shortcodes for tabs, as described in the documentation.

      When I insert the following code:


      [pl_tabs][pl_tabtitlesection type="tabs"] [pl_tabtitle number="1"]Title 1[/pl_tabtitle] [pl_tabtitle number="2"]Title 2[/pl_tabtitle] [/pl_tabtitlesection] [pl_tabcontentsection] [pl_tabcontent active="yes" number="1"] Lorem ipsum dolor sit amet, consectetur adipiscing elit [/pl_tabcontent] [pl_tabcontent number="2"] Lorem ipsum dolor sit amet, consectetur adipiscing elit [/pl_tabcontent] [/pl_tabcontentsection] [/pl_tabs]

      I get a strange output (in the attachment).

      Any ideas?

      Thanks in advance!

    • MooiWeb
      By MooiWeb
      Hello,

      I would like to align my qtranslate with my breadcrumb so that the flags are on the same hight.
      I'm aware of putting a code in the custom css and tryed severall codes from your site but for now, no succes

      The site i'm working on is http://nieuw.vazdias.nl

      Thx,
      Edwin



×