ThemeShaper Forums » Thematic

[closed]

Function above_content assist

(4 posts)
  • Started 8 years ago by squidz
  • Latest reply from squidz
  • This topic is not resolved
  1. I have a function that is setting different images for a photobanner in the above_content hook.

    // insert content space abovecontent
    
    function banner(){  ?>
    <div id="photobanner">
         <?php
            if (is_page('home')) {
    
                $banners ='ph_hm.jpg';
                }
                elseif ( is_page('about') ) {
                $banners = 'ph_mike_meeting.jpg';
                }
                elseif ( is_page('resources') ) {
                $banners = 'ph_books.jpg';
                }...etc...
                }
                else{$banners = 'ph_sam_board.jpg';}
    
                ?>
    
         <img src="<?php echo bloginfo('stylesheet_directory') . '/images/banners/' . $banners; ?>" />
         </div>
    <?php }
    
    add_action('thematic_abovecontent','banner');

    This is working great. However, I have a need to swap out the div that is inserted on customized author profiles, but not being very PHP savvy yet, I have not been able to make this work. So, if I'm on an author page, how do I modify this function to deliver my <div id="attorney_brief">stuff in here</div>?

    The attorney_brief div has a bunch of php stuff happening in it. But I think if I can just understand the syntax to load this div rather than the photobanner div, it'll work.

    Posted 8 years ago #
  2. How about using is_author().

    If you need a different div id you'll need to rearrange your logic so the div id is inside your conditional statements.

    Look at this page http://codex.wordpress.org/Conditional_Tags and bookmark it. It is invaluable.

    I am guessing you'll need some author specific stuff too? Not sure what functions you might need there, but dig around in the codex as these are Wordpress functions not thematic functions.

    Posted 8 years ago #
  3. Thank janimal. I looked at all the codex stuff and was using is_author. I had it all working..meaning the div was being replaced properly, but I could never get it to show the author specific content that needed to go in it. I believe it has something to do with when the $curauth is created in this case. I put it in functions.php in the author.php template etc. At least for now, I had to just stick the whole div and calls to the author's data directly into the template rather than hooking to thematic_abovecontent.

    I'll hack at it again later. I think some basic PHP skills are in order for me. So far I've worked from examples and a trial & error approach. That gets a bit tedious and is highly inefficient.

    Posted 8 years ago #
  4. Hello folks, I hate to come crawling back for more hand holding...but I can't seem to get this to fly.

    My Goal:
    1) on author pages deliver a div with author specific content to "thematic_abovecontent"
    2) on all others deliver a div with an image in it to "thematic_abovecontent"

    The Catch: I have this working, but I cannot get the author's content to display UNLESS I embed all the bio content div in the author.php child template. Then, I unfortunately, am not replacing the div I'm adding another and it doesn't work properly.

    I have isolated the author content display issue down to how/when/where the $curauth variable is set. In the template, great. From functions.php I get nifty div replace, no content. It comes down to the setting of $curauth. The div will replace fine without that chunk. But that chunk is critical to getting the current authors bio data I'm after. How can I get these things to work together?

    // insert content space abovecontent
    
    function banner(){
    	if(is_page()){?>
    
    <div id="photobanner">
         <?php
            if (is_page('home')) {
    
    			$banners ='ph_hm.jpg';
    			}
    			elseif ( is_page('about') ) {
    			$banners = 'ph_mike_meeting.jpg';
    			}
    			elseif ( is_page('resources') ) {
    			... a series of other images
                            }
    			elseif (!is_author()){
    			$banners = 'ph_abstract_1.jpg';
    			}
    
    		?>
         <img src="<?php echo bloginfo('stylesheet_directory') . '/images/banners/' . $banners; ?>" /> </div>
    
    <?php }
    elseif (is_author()){?>
         	<div id="attorney_brief">
              <?php if(isset($_GET['author_name'])) :
    				$curauth = get_userdatabylogin($author_name);
    			else :
    				$curauth = get_userdata(intval($author));
    			endif;
               ?>
            <br />
    <!--------         calls id of author         ------------->
            <h1 class="profile_title"> <?php echo $curauth->nickname;?> </h1>
           <div>
         <!-------- 	    calls bio intro of author		------------->
         <?php
    		if ($curauth->bio2){
    	?>
         <div><?php echo nl2br($curauth->bio2); ?></div>
         <?php } 
    
    			?>
           </div>
        </div> 
    
        <?php }
    }
    
    add_action('thematic_abovecontent','banner');
    Posted 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.