Jump to content
Sign in to follow this  
princealbert

Adding 2 more themes menus location.

Recommended Posts

princealbert

Hi, First I would like to thanks the development team for this amazing new 1.3.1 release. I face a request to have two menus on sidebar with text in between so I use the feature of CUSTOM SECTIONS. Here the code I use, to place in the sections folder of the Platformbase child theme : Sidebar Bottom Navigation

	<?php
	/*
	
		Section: Sidebar Bottom Navigation
		Author: Camille based on Adam Munns code
		Description: Creates site navigation.
		Version: 1.0.0
	
	*/
	
	class SideBarNavBottom extends PageLinesSection {
	
	   function __construct( $registered_settings = array() ) {
	
			$name = __('Sidebar Bottom Navigation', 'pagelines');
			$id = 'sidebarnavbottom';
	
			$default_settings = array(
				'workswith' => array('sidebar1', 'sidebar2', 'sidebar3', 'main'),
				'description' => 'Sidebar Site Navigation.',
				'icon'			=> CORE_IMAGES . '/admin/map.png'
			);
	
			$settings = wp_parse_args( $registered_settings, $default_settings );
			parent:GDN__construct($name, $id, $settings);
	   }
	
		// PHP that always loads no matter if section is added or not -- e.g. creates menus, locations, admin stuff...
		function section_persistent(){
	
			register_nav_menus( array( 'sidebarbottom' => __( 'Sidebar Bottom Navigation', 'pagelines' ) ) );
	
		}
	
	   function section_template() {?>
	
		<div id="secondary-nav">
	
			<?php if(function_exists('wp_nav_menu')):
				wp_nav_menu( array('menu_class'  => 'main-nav sf-menu', 'container' => null, 'container_class' => '', 'depth' => 3, 'theme_location'=>'sidebarbottom', 'fallback_cb'=>'nav_fallback') );
				endif;?>
		</div>
	
	<?php }
	
	}
	/*
		End of section class
	*/
	
Sidebar Top Navigation
	<?php
	/*
	
		Section: Sidebar top Navigation
		Author: Camille based on Adam Munns code
		Description: Creates site navigation.
		Version: 1.0.0
	
	*/
	
	class SideBarNavTop extends PageLinesSection {
	
	   function __construct( $registered_settings = array() ) {
	
			$name = __('Sidebar Top Navigation', 'pagelines');
			$id = 'sidebarnavtop';
	
			$default_settings = array(
				'workswith' => array('sidebar1', 'sidebar2', 'sidebar3', 'main'),
				'description' => 'sidebar Site Navigation.',
				'icon'			=> CORE_IMAGES . '/admin/map.png'
			);
	
			$settings = wp_parse_args( $registered_settings, $default_settings );
			parent:GDN__construct($name, $id, $settings);
	   }
	
		// PHP that always loads no matter if section is added or not -- e.g. creates menus, locations, admin stuff...
		function section_persistent(){
	
			register_nav_menus( array( 'sidebartop' => __( 'Sidebar Top Navigation', 'pagelines' ) ) );
	
		}
	
	   function section_template() {?>
	
		<div id="primary-nav">
	
			<?php if(function_exists('wp_nav_menu')):
				wp_nav_menu( array('menu_class'  => 'main-nav sf-menu', 'container' => null, 'container_class' => '', 'depth' => 3, 'theme_location'=>'sidebartop', 'fallback_cb'=>'nav_fallback') );
				endif;?>
		</div>
	
	<?php }
	
	}
	/*
		End of section class
	*/
	
Registered our custom sections in function.php
	....
		function base_sections(){
	
		/*
			Your custom sections get registered in here...
			PageLines Register Section Arguments:
				1. Section Class Name,
				2. Directory name (or filename if in root of 'sections' folder),
				3. Init Filename (if different from directory name),
				4. Section setup and variable array
	*/
	
			pagelines_register_section('BasePullQuote', 'pullquote', null, array('child' => true) );
			pagelines_register_section('BaseSidebar','sb_base', null, array('child' => true) );
			pagelines_register_section('SideBarNavTop', 'sidebar_nav_top', null, array('child' => true) );
			pagelines_register_section('SideBarNavBottom', 'sidebar_nav_bottom', null, array('child' => true) );
		}
	....
	

here the example web site cha.camille.pro If this can help I will be glad ! Camille

Share this post


Link to post
Share on other sites
kastelic

Awesome, thanks. Everything working for you right?

Share this post


Link to post
Share on other sites
princealbert

Hi Jimmmy, Yes thanks, just to be a freelance web developer/designer living in south of France it's not so easy !!!

Share this post


Link to post
Share on other sites
loraxio

I also needed to add the Secondary Nav to the Sidebar, but I can't seem to see the two custom sections in the Template admin area (under Sidebar 1 or 2). Any assistance would be appreciated. FYI, I created the two files and named them sidebar_nav_bottom.php & sidebar_nav_top.php and uploaded them to the Base Sections folder...I also made the changes to the functions.php file adding the two new sections. Nothing so far. Would be great to get it working. Here is the site so far http://wcoga.com/beta

Share this post


Link to post
Share on other sites
timlinson
I also made the changes to the functions.php file adding the two new sections.
What's the exact code you used to register the sections?

Share this post


Link to post
Share on other sites
loraxio

Copied and pasted from above.

Share this post


Link to post
Share on other sites
loraxio

Tim, This is what my functions.php file looks like in the section with the added sections:

<?php
	
	// Setup  -- Probably want to keep this stuff...
	// Set up action for section registration...
	add_action('pagelines_register_sections', 'base_sections');
	
	/**
	 * Hello and welcome to Base! First, lets load the PageLines core so we have access to the functions
	 */
	require_once( dirname(__FILE__) . '/setup.php' );
	
	// For advanced customization tips & code see advanced file.
		//--> require_once(STYLESHEETPATH . "/advanced.php");
	
	// ====================================================
	// = YOUR FUNCTIONS - Where you should add your code  =
	// ====================================================
	
	// ADDING CUSTOM SECTIONS ------- //
		// Register a Drag&Drop HTML Section for the admin.
		// A pullquote section was created here for demonstration purposes
	
		// Sections should be named: section.[your section name].php and placed in the sections folder.
	
		function base_sections(){
	
		/*
			Your custom sections get registered in here...
			PageLines Register Section Arguments:
				1. Section Class Name,
				2. Directory name (or filename if in root of 'sections' folder),
				3. Init Filename (if different from directory name),
				4. Section setup and variable array
	*/
	
			pagelines_register_section('BasePullQuote', 'pullquote', null, array('child' => true) );
			pagelines_register_section('BaseSidebar','sb_base', null, array('child' => true) );
			pagelines_register_section('SideBarNavTop', 'sidebar_nav_top', null, array('child' => true) );
			pagelines_register_section('SideBarNavBottom', 'sidebar_nav_bottom', null, array('child' => true) );
	
		}
	

Share this post


Link to post
Share on other sites
cmunns

If there is nothing showing up it means that you have not registered them correctly. what does your functions.php file say

Share this post


Link to post
Share on other sites
cmunns

if you copied exactly it should be showing up. Do you have the menu and just not the section or vice versa?

Share this post


Link to post
Share on other sites
loraxio

neither show for me... i am assuming they should be showing up in the Template Setup area of the settings. I have actually gotten the concept working with a plugin called page-list that allows you to only show pages that are related to the parent...works great. I think I can get by with the plugin. But it is weird that I con't get the custom section working. I think that in the future I might want to try and get that kinda thing working.

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  

×