Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Sidebars & Widgets (http://forum.bytesforall.com/forumdisplay.php?f=14)
-   -   Using ATA Custom Field to turn off sidebars (http://forum.bytesforall.com/showthread.php?t=23218)

riw777 Jun 17, 2015 01:10 PM

Using ATA Custom Field to turn off sidebars
 
Y'all --

I know this bit of code:

if ($bfa_ata['left_col_pages_exclude'] != "") {
$pages_exlude_left = explode(",", str_replace(" ", "", $bfa_ata['left_col_pages_exclude']));
if ( isset($bfa_ata['leftcol_on']['page']) AND !in_array($current_page_id, $pages_exlude_left) ) {
$cols++; $left_col = "on";
}
} else {
if ( isset($bfa_ata['leftcol_on']['page']) ) {
$cols++; $left_col = "on";
}
}

Controls whether the left sidebar is displayed or not. I can reverse this, of course, but I'd actually like to be able to do something a little different -- I'd like to set it up so the presence of an ATA custom class or variable attached to the page controls whether or not the sidebars are shown. I use this theme on a college site with 100 pages already, and now that I'm moving the entire catalog online, I'm bound to be adding a few more. Listing pages individually to add or remove the sidebars from is getting really difficult, to be honest. A variable, or the ability to use a category (I've tried this and it doesn't work), would be really nice.

Thoughts?

riw777 Jun 17, 2015 01:32 PM

Looking at bfa_get_options.php, it looks like the easiest thing to do might be to remove all of the if/elseif stuff around what type of page this is, etc., and just leave the code for categories. So remove everything from:

if (( is_page() AND !is_front_page() AND !is_home() )
OR (function_exists('is_bbpress')) ) {
...
} elseif ( is_category() ) {

Leave the inner section of the is_category section, and take out the final "else" as well... This would disable all the "don't display on" controls on the settings pages other than the "don't display on category," section. I would need to do this each of the four sidebars in bfa_get_options, from what I can tell.

This would leave the control of whether or not to display a particular sidebar completely in the hands of each page or post being in the right category.

Would this work, or am I missing something here/making a mess of things?

Thanks!

Russ

juggledad Jun 17, 2015 02:05 PM

The thing is, you don't assign categories to pages....that code will remove the sidebar of a 'category' page - i.e. when you click on category 'x' and it shows a category page of all the posts in that category, then the sidebar won't show on that page

juggledad Jun 17, 2015 02:23 PM

see this thread to make a page template for something like what you want
HOWTO: create a 'no sidebar' template (or 1, 2, 3 or 4 sidebar template)

change the code
HTML Code:

$left_col ="off";
$left_col2 = "off";
$right_col2 = "off";
$right_col = "off";

to what you want, name teh template and use it on the pages you want.

riw777 Jun 17, 2015 02:28 PM

Quote:

Originally Posted by juggledad (Post 112450)
see this thread to make a page template for something like what you want
HOWTO: create a 'no sidebar' template (or 1, 2, 3 or 4 sidebar template)

Aha! I hadn't thought of using a template for all the pages. I'll try that.

Thanks!

riw777 Jun 17, 2015 05:12 PM

One other question -- when I use the template, it leave the space for the sidebar... I'm pretty certain this is td#middle on that page, but is there some way to modify the new php to force the middle to go 100% width within the wrapper? Or do I need to this with custom css per page?

Thanks!

:-)

Russ

juggledad Jun 17, 2015 06:30 PM

Hmmm my version of the template doesn't - did you make the change to header.php as it says in the thread?

riw777 Jun 17, 2015 08:18 PM

This is what I have --

<?php
/*
Template Name: nosidebar
*/
?>
<?php
list($bfa_ata, $cols, $left_col, $left_col2, $right_col, $right_col2, $bfa_ata['h_blogtitle'], $bfa_ata['h_posttitle']) = bfa_get_options();

$left_col ="off";
$left_col2 = "off";
$right_col2 = "off";
$right_col = "off";

get_header();
extract($bfa_ata);
global $bfa_ata_postcount;
?>


And this is the resulting page --

https://shepherds.edu/about-shepherd...effectiveness/

It looks like the page text ends just where the sidebar should start... I was thinking it might want to make the middle column of the layout table what it was without the sidebar, but I'm not certain.

Thanks!

:-)

Russ

riw777 Jun 17, 2015 08:22 PM

Aha -- I found it -- I didn't do the header.php file correctly.

Thanks!

:-)

Russ


All times are GMT -6. The time now is 07:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.