Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Modification of Karma Theme through TrueThemes WordPress

  • SOLVED

In the current theme there is a template that sets 3 columns. A sub navigation in one column, content in one column and a sidebar in one column. The template is called nav + sidebar.

In the edit page view you are able to select a sidebar that is called into the page. Multiple sidebars can be created within the theme so there is a dropdown of all the sidebars created.

I need to be able to add an additional sidebar element that will go under the subnavigation. The subnavigation is created dynamically and currently there is not way to add a sidebar or widgets below it. Please see the markup - http://markup.io/v/7erhcqfe13qy. So I asking for 2 sidebars to be called.

This would also have to to added to the edit page as an additional sidebar selection. Please see the attached image for placement.

The plan for this area is to add testimonials that have their own styling, different coloring and colored quotes so a sidebar with widgets would be optimal.

Thank you for your time.

Update:
I have attached the template code that needs altering.

Main template

<?php
/*
Template Name: Left Nav + Sidebar
*/
?>
<?php get_header(); ?>
</div><!-- header-area -->
</div><!-- end rays -->
</div><!-- end header-holder -->
</div><!-- end header -->

<?php truethemes_before_main_hook();// action hook, see truethemes_framework/global/hooks.php ?>

<div id="main">
<?php get_template_part('theme-template-part-tools','childtheme'); ?>

<div class="main-holder">
<?php get_template_part('theme-template-part-subnav-left','childtheme'); ?>

<div id="content" class="content_sidebar content_right_sidebar">
<?php if(have_posts()) : while(have_posts()) : the_post(); the_content(); truethemes_link_pages(); endwhile; endif; ?>
</div><!-- end content -->

<div id="sidebar">
<?php generated_dynamic_sidebar(); ?>
</div><!-- end sidebar -->
</div><!-- end main-holder -->
</div><!-- main-area -->

<?php get_footer(); ?>


Theme template part subnav left

<div id="sub_nav">
<?php wp_nav_menu(array('theme_location' => 'Primary Navigation' , 'depth' => 0 , 'container' =>false , 'walker' => new sub_nav_walker() )); ?>
</div><!-- end sub_nav -->

<?php
function removeEmptyTags($html_replace)
{
$pattern = "/<[^\/>]*>([\s]?)*<\/[^>]*>/";
return preg_replace($pattern, '', $html_replace);
}
?>

Answers (4)

2011-11-29

Luis Abarca answers:

You want to add something like this ?? to show a different sidebar in each page ?

I can help you, i just need the menu or the template to show the selected sidebar


Luis Abarca comments:

Here is the code to show a dropdown with the current sidebars and save the selected item to a custom post meta.

The pastebin version
http://pastebin.com/BX65gPdx


<?php
/*
Plugin Name: Custom Sidebars
*/

add_action('add_meta_boxes', 'sidebar_meta_boxes');

function sidebar_meta_boxes()
{
add_meta_box( 'sidebar_metabox-1', __( 'Custom sidebar' ), 'sidebar_meta_box_content', 'page', 'normal', 'high');
}

// }}}
// {{{

function sidebar_meta_box_content()
{
global $post;
global $wp_registered_sidebars;

$selected = get_post_meta($post->ID, 'menu-sidebar', true);

wp_nonce_field('sidebar_save', 'sidebar_nonce');
?>
<div class="jaxtag">
<div class="ajaxtag hide-if-no-js">
<table style="width: 100%">
<tr>
<td width="25%">
<label for="menusidebar"><?php _e('Menu sidebar') ?>:</label>
<label class="screen-reader-text" for="menusidebar"><?php _e('Menu sidebar') ?>:</label>
</td>
<td width="75%">
<select name="menusidebar" id="menusidebar">
<?php foreach ($wp_registered_sidebars as $sidebar) : ?>
<option value="<?php echo $sidebar['id'] ?>" <?php echo (($selected == $sidebar['id']) ? 'selected="selected"' : '') ?>><?php echo $sidebar['name'] ?></option>
<?php endforeach ?>
</select>
</td>
</tr>
</table>
</div>
</div>

<?php
}


add_action('save_post', 'sidebar_save_postdata', 10, 2);

function sidebar_save_postdata( $post_id )
{
global $wpdb;

if ( !wp_verify_nonce( $_POST['sidebar_nonce'], 'sidebar_save' ) ) {
return $post_id;
}

if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
return $post_id;
}
// Check permissions ....

$menusidebar = trim($_POST['menusidebar']);

if ( !empty($menusidebar) ) {
update_post_meta($post_id, 'menu-sidebar', $menusidebar);
}
}


Luis Abarca comments:

I update the pastebin

use this in your template below your menu


<?php show_custom_sidebar() ?>


Luis Abarca comments:

And this is a working example:

http://dev.justoalblanco.com/pagina-ejemplo/
http://dev.justoalblanco.com/custom-sidebar-2/

I'm using twenty eleven, with the sidebar template for pages.

This is my sidebar.php


<?php
/**
* The Sidebar containing the main widget area.
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/

$options = twentyeleven_get_theme_options();
$current_layout = $options['theme_layout'];

if ( 'content' != $current_layout ) :
?>
<div id="secondary" class="widget-area" role="complementary">
<?php if ( ! dynamic_sidebar( 'sidebar-1' ) ) : ?>

<aside id="archives" class="widget">
<h3 class="widget-title"><?php _e( 'Archives', 'twentyeleven' ); ?></h3>
<ul>
<?php wp_get_archives( array( 'type' => 'monthly' ) ); ?>
</ul>
</aside>

<aside id="meta" class="widget">
<h3 class="widget-title"><?php _e( 'Meta', 'twentyeleven' ); ?></h3>
<ul>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<?php wp_meta(); ?>
</ul>
</aside>

<?php endif; // end sidebar widget area ?>

<blockquote> <strong>CUSTOM SIDEBAR for post <?php echo get_the_ID() ?></strong>
<?php show_custom_sidebar() ?>
</blockquote>

</div><!-- #secondary .widget-area -->
<?php endif; ?>


Luis Abarca comments:


<div id="sub_nav">
<?php wp_nav_menu(array('theme_location' => 'Primary Navigation' , 'depth' => 0 , 'container' =>false , 'walker' => new sub_nav_walker() )); ?>
</div><!-- end sub_nav -->
<strong><?php show_custom_sidebar() ?></strong>

<?php
// You should move this function to functions.php
function removeEmptyTags($html_replace)
{
$pattern = "/<[^\/>]*>([\s]?)*<\/[^>]*>/";
return preg_replace($pattern, '', $html_replace);
}
?>


Carlos Lopez Jr comments:

I like what your doing here. Can you look at the template I posted and see how you would implement this.
thanks


Luis Abarca comments:

Yep, can you send me ftp or login details via PM ?


Carlos Lopez Jr comments:

I will send you login information via google doc. What email should I use?


Luis Abarca comments:

Hey Carlos,
Can you have a look and test if works as you want it ?

2011-11-29

Julio Potier answers:

Hello !

I can handle this, but of course need an admin account and FTP account too.

Can you provide me this via PM ?

Thank you


Carlos Lopez Jr comments:

Hi Julio,
What would your turn around time be. I have not chosen anyone yet but I do need this completed quickly.
Thank you.


Julio Potier comments:

I'm available right now for the next 2 (or maybe 3) hours. gogogo !


Julio Potier comments:

1 hour left ;)
I'll be available in 8 hours too (i'm french, so i'l be up @ 7am, it's 11pm right now)


Julio Potier comments:

I'm up. PM me.

2011-11-29

Kannan C answers:

Multiple widgets can be posted in to sidebars. Cannot you drag a text widget under the services sidebar? it is difficult to answer without the theme code


Carlos Lopez Jr comments:

I added the code. This needs to be dynamic. So I want to have this extra sidebar code placed below the subnav content. So I can go into the edit page or edit post and add an additional sidebar from a dropdown that shows all the sidebars that I have created.

The client wants to be able to add different widget items in that area for individual pages.

I hope this make sense.

Thank you for your reply.

Carlos


Kannan C comments:

Install this plugin http://wordpress.org/extend/plugins/custom-sidebars/
this will create multiple sidebars on the go. Define some sidebar locations in your template files. in your case


<div id="sub_nav">
<?php wp_nav_menu(array('theme_location' => 'Primary Navigation' , 'depth' => 0 , 'container' =>false , 'walker' => new sub_nav_walker() )); ?>
</div><!-- end sub_nav -->
<?php if(dynamic_sidebar( 'Top sidebar' )) //'Top sidebar' - name of the sidebar created from the plugin
?>
<?php
function removeEmptyTags($html_replace)
{
$pattern = "/<[^\/>]*>([\s]?)*<\/[^>]*>/";
return preg_replace($pattern, '', $html_replace);
}
?>

Once done that, you can then select sidebars to show on specific page or even interchange sidebar locations for a page.