Jump to content
Sign in to follow this  
myohanan

Custom Templates and Custom Sidebar Sections

Recommended Posts

myohanan

Agh. This upgrade destroyed everything I had built. All of my custom page templates and custom sidebar sections are gone. I downloaded the custom sections plug-in. The documentation within this plugin is not very detailed on how to recreate my templates and sections. For the Templates:

// ---- ADDING NEW TEMPLATES ---- // Want another page template for drag and drop? Easy :) 1. Add File called page.[page-id].php to this folder. 2. Add Template Name: Your Page Name to that file ( see page.base.php for an example. ) 3. Thats it! We do the rest for you!
This process looks the same as PlatformBase, minus having to register the section in the function.php file. When I do create these new files in pagelines-customize folder, the templates are not automatically created in either the pagelines admin section or in the edit page section. What am I missing? For example I have a file titled page.contact.php with this inside:
<?php
	/*
		Template Name: Contact
	*/
	
	setup_pagelines_template();
For the new Sections:
// ---- ADDING NEW SECTIONS ---- // Adding new sections is really easy in 2.0 1. Copy your section.[sectionname].php file into the sections folder 2. It will be auto loaded for you. 3. You can now enable/disable the section in the extensions menu.
I am trying to just copy all my sidebars over because I had created many. For example in the pagelines-sections folder I copied my file section.sb_employeepics.php It contains:
<?php
	/*
	
		Section: Employee Pics Sidebar
		Author: Andrew Powers
		Description: The main widgetized sidebar
		Version: 1.0.0
	
		Note: the only other piece to make this work is the 'pagelines_register_section()' function in your functions.php
	
	*/
	
	class EmployeePics extends PageLinesSection {
	
	   function __construct( $registered_settings = array() ) {
	
			/* The name and ID of the section */
			$name = __('Employee Pics Sidebar', 'pagelines');
			$id = 'sidebar_employeepics';
	
			/* Setup description, areas it works with, icon, etc...*/
			$default_settings = array(
				'description' 	=> 'A new widgetized sidebar section created by Base. It can be used in standard sidebar templates.',
				'workswith' 	=> array('sidebar1', 'sidebar2', 'sidebar_wrap', 'main'),
				'icon'			=> CORE_IMAGES . '/admin/sidebar.png'
			);
	
			/* Draw section using the section API */
			$settings = wp_parse_args( $registered_settings, $default_settings );
		   	parent::__construct($name, $id, $settings);
	   }
	
		/* Setup widgetized areas */
	   function section_persistent() {
			$setup = pagelines_standard_sidebar($this->name, $this->settings['description']);
			register_sidebar($setup);
		}
	
	
		/* Standard Sidebar Template e.g. widgets */
	   function section_template() {
		 	 pagelines_draw_sidebar($this->id, $this->name);
		}
	
	}
	
	/*
		End of section class
	

No section is created when I add this. For now, I have reverted back to Platformpro with Base. Please let me know what I should be doing or create more detailed documentation on the subject. Thanks!

Share this post


Link to post
Share on other sites
myohanan

Thanks for the response Kastelic. Are there any samples available? I'm not a developer and built most of my duplicate sidebars by recreating the given base sidebar sample in platformbase. Also, any idea on what I'm doing wrong with new templates? Michael

Share this post


Link to post
Share on other sites
myohanan

AH! I was missing the pagelines section template. I'll use that now as a guide.

Share this post


Link to post
Share on other sites
myohanan

Yes, yes, yes! I figured out the sidebar cloning, thank you. I just needed a push in the right direction. In case anyone needs their hand held as well, watch that video. But basically, if you want to clone a sidebar - after you download the pagelines-section-template, duplicate it and save it in the pagelines-section folder (both are within the wordpress plugin area after you download them from the pagelines store, not in the theme area). Then within the duplicated and renamed template folder delete all the code in the section.php file and replace it with:

<?php
	/*
		Section: Primary Sidebar
		Author: PageLines
		Author URI: http://www.pagelines.com
		Description: The main widgetized sidebar.
		Class Name: PrimarySidebar
		Workswith: sidebar1, sidebar2, sidebar_wrap
	*/
	
	class PrimarySidebar extends PageLinesSection {
	
	   function section_persistent() {
			$setup = pagelines_standard_sidebar($this->name, $this->settings['description']);
			register_sidebar($setup);
		}
	
	   function section_template() {
		 	 pagelines_draw_sidebar($this->id, $this->name, 'includes/widgets.default');
		}
	
	}
	
	/*
		End of section class
	*/

Making sure to rename every instance of PrimarySidebar to whatever you want to call your new sidebar. Then go to the pagelines store in your wordpress admin and make sure the new sidebar section is activated!

Share this post


Link to post
Share on other sites
myohanan

Catrina, sorry, one last question. Still can't figure out why my templates aren't appearing. In pagelines-customize (the plugin I downloaded to make function.php and style.css changes), I have created a number of files with the naming structure of

page.contact.php
Then, within that File:
<?php
	/*
		Template Name: Contact Page
	*/
	
	setup_pagelines_template();
	

Share this post


Link to post
Share on other sites
myohanan

What about the templates? Not being able to create new custom templates is killing me. The direction in the customize plugin do not seem to be working. Please help.

Share this post


Link to post
Share on other sites
michaeljaekel

@myohanan Hi, Just in case you didn't resolve your problem: please double check that you created your new page file in ../wp-content/plugins/pagelines-customize/[new page file] instead of ../themes/pagelines/[new page file] After moving my file to that correct directory the new page template was shown at the admin.

Share this post


Link to post
Share on other sites
tpldrew

I too have added a template to the ../wp-content/plugins/pagelines-customize/[new page file] but it's not showing up in my "special" admin section. I'm hoping to spend time with setting up the pagelines 2.0 new site this weekend any guidance would be greatly appreciated. Specifically, do I need to add anything to functions.php to register the page?

Share this post


Link to post
Share on other sites
krnlhkr

Yes, I'm having the same problem with templates that tpldrew, jcritty, and myohanan are having. In fact, after I install the customize plugin, I'm not even seeing the default "Custom Page" template that should show up under templates let alone my own. I pretty much need this functionality for the site I'm working on, so any advice would be great. WP 3.3.1 with PageLines Framework 2.0.1. If it helps, it's shared hosting that doesn't use suexec, but it doesn't seem like a perms problem. Thanks! Edit to add: Just found out if I drop my page.base.php file into wp-content/themes/pagelines it is picked up, but not under the customize folder, so something is apparently busticated with the customize plugin and custom page templates.

Share this post


Link to post
Share on other sites
Simon

It isnt 'busticated' as you put it lol. The plugin will only copy the page file to the active theme, be it a child o parent IF it has permissions to do so, if not it just wont. So if this is the case, just put the page file into your child/parent theme folder.

Share this post


Link to post
Share on other sites
krnlhkr

Well, I think that it is busticated. ;-) I'll tell you why. According to the customize plugin I should just be able to drop a page template under wp-content/plugins/pagelines-customize, right? And then it should be picked up. Say I have a page template page.home.php If I put my page template *only* under: wp-content/themes/pagelines It doesn't show up in page lines control under templates. If I put it *only* under: wp-content/plugins/pagelines-customize/ Same thing, it doesn't show up. But if I put it under *both* it shows up and the name in the comment is pulled from the wp-content/themes/pagelines version. It *seems* like it is getting the list of files from wp-content/plugins/pagelines-customize/ but trying to pull the content for those files from wp-content/themes/pagelines Maybe something is using the wrong path to include the file and the right path to get the list of files? The problem doesn't happen with function.php; that's pulled in correctly from the pagelines-customize subdir. It's only the page templates that are having a problem.

Share this post


Link to post
Share on other sites
Simon

Yes, it does have to be in both to show up, sorry lol. The templates are scanned in the customize folder and if it can copy it, it moves it to the theme folder, if its successful it will be registered into the framework for use. Wordpress will only read templates from the theme folder, no way around this.

Share this post


Link to post
Share on other sites
krnlhkr

Ah OK. Now it makes sense :-) But that's kind of a problem for shared hosting. The files are owned by my ftp account but the server runs as "nobody" so the server can't copy files over unless I chmod everything to 777, which I don't want to do in my pagelines theme directory for obvious reasons. Some hosts use suexec so the server runs as the FTP account, but some don't. I got "lucky" and have one that doesn't. That's why I have to type in my FTP info when I install stuff, sigh. So for those of us in this situation, we should just put the page template in both places? Thanks, I appreciate the help!

Share this post


Link to post
Share on other sites
Simon

Yes you should, and you should ask your host why you do not own your own files, bear in mind that all sites on the server will be owned by the webserver, so you could read any file in anybodies webroot including sensitive config files!

Share this post


Link to post
Share on other sites
krnlhkr

OK, thanks, Simon. Oh I think you misunderstood me. The files are owned by me. But the apache server runs as "nobody" so when it runs the .php code, it doesn't have permissions to write in my directories via the php. suexec tells the apache server to run as me so when the php code is executed, it does have permissions to write in my directories. WordPress actually has a buried document on this exact issue, here: http://codex.wordpress.org/Changing_File_Permissions#Permission_Scheme_for_WordPress Thanks again for the help! I'm up and running again. :)

Share this post


Link to post
Share on other sites
Simon

suexec is for perl scripts not php ;) Your scripts are running as nobody trust me, thats why you have to set them 777 to allow nobody to write to your files. How to test, create a simple php script in your home folder, use file_put_contents( 'hello.txt', 'abc' ); it should create the file hello.txt, see who owns the file, my bet it will be nobody! BTW you wont be able to delete the file then because it will be ownded by apache, you will have to use phps unlink() to delete it.

Share this post


Link to post
Share on other sites
devaldivia

I wanted to create a new sidebar, followed the instructions as per: myohanan , and it worked perfect! I know, just got lucky :) but still, wanted to say Thank You!

Share this post


Link to post
Share on other sites
jankowalski

@kastelic Hello, provided links are broken, where can i learn how to construct custom sections?

Share this post


Link to post
Share on other sites
smv_usdam

I just bought Pagelines recently and also would like to create custom templates. @krnlhkr wrote:

Say I have a page template page.home.php If I put my page template *only* under: wp-content/themes/pagelines It doesn't show up in page lines control under templates. If I put it *only* under: wp-content/plugins/pagelines-customize/ Same thing, it doesn't show up. But if I put it under *both* it shows up and the name in the comment is pulled from the wp-content/themes/pagelines version.
Unfortunately if I do the same it doesn't show up. Pagelines Wiki also doesn't help at all: http://www.pagelines.com/wiki/How_to_Create_a_Custom_Page_Template And @kastelic: As pointed out long time ago, the links to the video tutorials produce a 404 error. Any ideas?

Share this post


Link to post
Share on other sites
jschm

I am also struggling with this problem (@smv_usdam). Is there anyone who could help, please?

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  

×