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)
-   -   New widget area in header (http://forum.bytesforall.com/showthread.php?t=2222)

paulae Jun 30, 2009 09:19 AM

New widget area in header
 
I think I'm almost there. I've told functions.php that I want a third widget area. I want to place the code for it in the logo area, where at the moment I have a cgi script running. The area in red is what I want to change, to the new widget spot, where I intend to use another instance of Sponsors Slideshow widget in bfa_header_config.php:
Code:

        // END of title/description
$logo_area .='
    <td height=125 colspan="2" rowspan="2" valign="middle" class="header-banner">
        <a href="http://www.larchmontgazette.com"><img src="http://www.larchmontgazette.com/wp27/wp-content/uploads/2009/05/bluegazebo500x120.jpg" width=500 height=120 align=left border=0></a>
    </td>
    <td rowspan="2" align="right" class="header-banner">';

if ( is_category('Obituaries') OR ( is_single() AND in_category('Obituaries') ) ) {

// Code for category Obituaries
$logo_area .='<script language=javascript src="http://www.larchmontgazette.com/cgi-bin/csBanner2/csBanner.cgi?g=2&js=Y"></script>
</script>';

} elseif ( is_category('Garden Guide') OR ( is_single() AND in_category('Garden Guide') ) ) {

// Code for category Garden Guide
$logo_area .='<script language=javascript src="http://www.larchmontgazette.com/cgi-bin/csBanner2/csBanner.cgi?g=4&js=Y"></script>
';

} else {

// Code for all other pages
$logo_area .='<script language=javascript src="http://www.larchmontgazette.com/cgi-bin/csBanner2/csBanner.cgi?g=240&js=Y&ss=Y"></script>';


}

$logo_area .='</td>
';

When I placed
Code:

$logo_area .=<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(3) ) : ?>
<?php endif; ?>;

there, I got a totally blank page. I must have somehow broken all the code on the page. I quickly put back the saved version of the file, and things are back to normal, but I really need to do this soon. I know Flynn is close to releasing a version of the theme that will have more widget areas, but I think the cgi script is really slowing down my site. http://www.larchmontgazette.com

juggledad Jun 30, 2009 10:00 AM

Paulae,
you have 2 </script>'s at the end of the // Code for category Obituaries code

paulae Jun 30, 2009 10:04 AM

Hmmm. Funnily enough, it wasn't causing any problems before, and I swear I didn't touch that part this time.

Otherwise, do you think the php code about the widget should have worked?

juggledad Jun 30, 2009 10:38 AM

The code you are adding is messing up. You are already in php so you are setting $logo_area to a value, but in this code

PHP Code:

$logo_area .=<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(3) ) : ?>
<?php 
endif; ?>;

you are going back into PHP again. This causes the rest of the code in the program to get out of wack. I think you want to add quotes around the statement like this
PHP Code:

$logo_area .='<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(3) ) : ?>'
endif;

of course I'm not sure what you are trying to do. This will just set the $logo_area to the string '<?php...' but I think you just want this to be another else if and then set $logo_area to what you want there.

paulae Jun 30, 2009 10:50 AM

I am trying to use that spot as a widget area, in which I'll place an instance of Sponsors Slideshow widget, which provides a very nice fade effect between ads, and I think it will be less of a load-hog than the cgi Perl script running the 3 banners now.

I'm going to try it again with the code just as you show it.

UPDATE: Nope, that produced a totally blank page too. Thanks for your efforts; maybe I should just wait until the theme is ready for the widgets up there, and I can also upgrade the theme to whatever is current.

juggledad Jun 30, 2009 03:03 PM

Paulae,

I think you want to do something like this
HTML Code:

if ( function_exists('dynamic_sidebar') && dynamic_sidebar(3) ) {
$logo_area .= '<what ever the html you want to use goes here>';
}

so if the dynamic_Sidebar function exists and there is a dynamic_sidebar (3) add this some code to the logo area.

paulae Jun 30, 2009 07:54 PM

What needs to go in there is the code to say "this is this new widget area," and doesn't that have to be some PHP code?

juggledad Jul 1, 2009 04:32 AM

I think that is what you would be doing. $logo_area is all the HTML code that makes up the logo area. So you will be adding to that area. As an experiment, you could just add the garden club script there and see if it shows up in the third position. Good luck, I'll check back late Sunday

paulae Jul 1, 2009 04:41 AM

Have a great Fourth!

For when you get back: the "HTML that you want in there" doesn't make sense to me in this case. Aren't I just calling whatever widget is assigned to sidebar 3? What would I put between the '' after logo area?

In any case, I put in the most recent code you suggested and just left the area between the '' blank, and got the blank white page again. So I've reverted to what was working, and will wait to see what you think when you get back. We should all (Americans, that is) get outside and enjoy the beginning of summer. It's been more like early spring in the northeast.

juggledad Jul 1, 2009 05:02 AM

You could call the widget, but it would not be assigned as a value to $logo_area. You would have:
$logo_area .= my_new_function(my_option);
not
$logo_area .= 'my_new_function(my_option)';
this second one just adds that text to $logo_area. And if you did
$logo_area .= '<php my_new_function(my_option); ?>';
I'm pretty sure that this would try to run on the client side since it would be part of the generated page, instead of the server side WHILE you are generating the page.
Try this inplace of your red code below and see if you get three areas in the logo
HTML Code:

if ( function_exists('dynamic_sidebar') && dynamic_sidebar(3) ) {
$logo_area .= '<script language=javascript src="http://www.larchmontgazette.com/cgi-bin/csBanner2/csBanner.cgi?g=240&js=Y&ss=Y"></script>';
}

And yes it was a wet and cold July - We had a nice day yesterday, so I headed out for a ride on my Vesppa with a friend nad we headed to Hingham, MA. the closes we got to the ocean, the more clouds and the colder it got. We finally turned around and headed back inlane where it was a broiling 70 degrees. Have a safe and happy fourth

paulae Jul 3, 2009 01:45 PM

Thanks, JD. I'm too pooped and happy to dig into code now, so I'll re-read this later. Lovely day on Martha's Vineyard, even though it started out foggy at this end of the island and threatened to storm a bit. Turned out beautiful and warmer than it's been in a while. I spent what seemed like all morning bailing the rainwater out of my little sailboat, and gave up after I got it down at least to the sole. The handpump will work on the remaining water tomorrow, when I'll try my first race.

I'm not sure where Hingham is, but I hope you have good weather wherever you are, too.


All times are GMT -6. The time now is 03:54 PM.

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