ThemeShaper Forums » Thematic

[closed]

Help with if/else/elseif for postfooter

(2 posts)
  • Started 8 years ago by Solomon
  • Latest reply from Solomon
  • This topic is resolved

Tags:

  1. What I want to do is alter the postfooter so I can edit the postfooter for posts of a certain category ("quick"). My meager PHP skills are bumping up against my inability to grasp logic properly. Could someone look at this and tell me what I should do? I am really just blundering around at this point.

    function childtheme_override_postfooter() {
    	    global $id, $post;
    
    	    if ($post->post_type == 'page' && current_user_can('edit_posts')) { /* For logged-in "page" search results */
    	        $postfooter = '<div class="entry-utility">' . thematic_postfooter_posteditlink();
    	        $postfooter .= "</div><!-- .entry-utility -->\n";
    	    } elseif ($post->post_type == 'page') { /* For logged-out "page" search results */
    	        $postfooter = '';
    	    } elseif (is_single() && in_category('quick')) {
    	            $postfooter = '<div class="entry-utility">' . thematic_postfooter_postcategory() . '<br class="cat-links" />' . thematic_postfooter_posttags() . '<br class="meta-sep-tag-links" />' . thematic_postfooter_postconnect();
    	        } elseif (in_category('quick')) {
    	            $postfooter = '<div class="entry-utility">' . thematic_postfooter_postcategory() . '<br class="cat-links" />' . thematic_postfooter_posttags() . '<br class="meta-sep-tag-links" />' . thematic_postfooter_postcomments();
    	        }
    	        $postfooter .= "</div><!-- .entry-utility -->\n";   
    
    		else {
    	        if (is_single()) {
    	            $postfooter = '<div class="entry-utility">' . thematic_postfooter_postcategory() . '<br class="cat-links" />' . thematic_postfooter_posttags() . '<br class="meta-sep-tag-links" />' . thematic_postfooter_postconnect();
    	        } else {
    	            $postfooter = '<div class="entry-utility">' . thematic_postfooter_postcategory() . '<br class="cat-links" />' . thematic_postfooter_posttags() . '<br class="meta-sep-tag-links" />' . thematic_postfooter_postcomments();
    	        }
    	        $postfooter .= "</div><!-- .entry-utility -->\n";
    	    }
    
    	    // Put it on the screen
    	    echo apply_filters( 'thematic_postfooter', $postfooter ); // Filter to override default post footer
        } // end postfooter
    Posted 8 years ago #
  2. Well, I've been working on it. This is going to look pretty crazy, but it does seem to work. It's going to look especially crazy since I've also added code to enable sliding divs at the bottom of every post. (You can hide stuff you don't want to show, then click the link and the div will open up in sliding fashion, then slide back when you click again (requires a javascript in your header). My intention is to hide things like social sharing and donation links that I don't want messing up my front page's look and taking too much space.

    I want to emphasize that I don't program PHP (and have always become a bit confuzzled with if/then statements). I am working this through as I go, so if you know enough to laugh at this code and say, "Why are you repeating those lines over and over?" or something, I would welcome anyone re-writing this code more efficiently.

    Again, what this does is look at your post and allow you to change what goes into the footer of posts in the category "quick". This seems to be working, though I haven't used it much so problems may emerge.

    function childtheme_override_postfooter() {
    	    global $id, $post;
    
    	    if ($post->post_type == 'page' && current_user_can('edit_posts')) { /* For logged-in "page" search results */
    	        $postfooter = '<div class="entry-utility">' . thematic_postfooter_posteditlink();
    	        $postfooter .= "</div><!-- .entry-utility -->\n";
    	    } elseif ($post->post_type == 'page') { /* For logged-out "page" search results */
    	        $postfooter = '';
    	    } elseif (is_single() && in_category('quick')) {
    			$postfooter = '<div class="entry-utility">' . thematic_postfooter_postcategory() . '<br class="cat-links" />' . thematic_postfooter_posttags() . '<br class="meta-sep-tag-links" />' . thematic_postfooter_postconnect();
    			$postfooter .= '<br class=shareslide /><a href="javascript:;" onmousedown="toggleSlide('; //slidy div stuff -- if it borks, just delete it
    			$postfooter .= "'"; //slidy div stuff
    			$postfooter .= $id; //slidy div stuff
    			$postfooter .= "'"; //slidy div stuff
    			$postfooter .= ');" title="Email this post, share on social networking sites, or donate to Solomonia." class="click-share-slide">Click here to see more sharing options.</a>'; //slidy div stuff
    			$postfooter .= ' <span class="meta-sep meta-sep-slidydiv">|</span>'; //slidy div stuff
    			$postfooter .= '<div id="'; //slidy div stuff
    			$postfooter .= $id; //slidy div stuff
    			$postfooter .= '" style="display:none; overflow:hidden; height:200px; text-align:right;">'; //slidy div stuff
    			$postfooter .= '<p>Some garbage here!</p>'; //slidy div stuff
    			$postfooter .= '</div>'; //slidy div stuff
    			$postfooter .= "</div><!-- .entry-utility -->\n";
    	        }	elseif (in_category('quick')) {
    	        $postfooter = '<div class="entry-utility">' . thematic_postfooter_postcategory() . '<br class="cat-links" />' . thematic_postfooter_posttags() . '<br class="meta-sep-tag-links" />' . thematic_postfooter_postcomments();
    			$postfooter .= '<br class=shareslide /><a href="javascript:;" onmousedown="toggleSlide('; //slidy div stuff -- if it borks, just delete it
    			$postfooter .= "'"; //slidy div stuff
    			$postfooter .= $id; //slidy div stuff
    			$postfooter .= "'"; //slidy div stuff
    			$postfooter .= ');" title="Email this post, share on social networking sites, or donate to Solomonia." class="click-share-slide">Click here to see more sharing options.</a>'; //slidy div stuff
    			$postfooter .= ' <span class="meta-sep meta-sep-slidydiv">|</span>'; //slidy div stuff
    			$postfooter .= '<div id="'; //slidy div stuff
    			$postfooter .= $id; //slidy div stuff
    			$postfooter .= '" style="display:none; overflow:hidden; height:200px; text-align:right;">'; //slidy div stuff
    			$postfooter .= '<p>Some garbage here!</p>'; //slidy div stuff
    			$postfooter .= '</div>'; //slidy div stuff
    			$postfooter .= "</div><!-- .entry-utility -->\n";
    	        }
    			else {
    	        if (is_single()) {
    	            $postfooter = '<div class="entry-utility">' . thematic_postfooter_postcategory() . '<br class="cat-links" />' . thematic_postfooter_posttags() . '<br class="meta-sep-tag-links" />' . thematic_postfooter_postconnect();
    	        } else {
    	            $postfooter = '<div class="entry-utility">' . thematic_postfooter_postcategory() . '<br class="cat-links" />' . thematic_postfooter_posttags() . '<br class="meta-sep-tag-links" />' . thematic_postfooter_postcomments();
    	        }
    	        $postfooter .= '<br class=shareslide /><a href="javascript:;" onmousedown="toggleSlide('; //slidy div stuff -- if it borks, just delete it
    			$postfooter .= "'"; //slidy div stuff
    			$postfooter .= $id; //slidy div stuff
    			$postfooter .= "'"; //slidy div stuff
    			$postfooter .= ');" title="Email this post, share on social networking sites, or donate to Solomonia." class="click-share-slide">Click here to see more sharing options.</a>'; //slidy div stuff
    			$postfooter .= ' <span class="meta-sep meta-sep-slidydiv">|</span>'; //slidy div stuff
    			$postfooter .= '<div id="'; //slidy div stuff
    			$postfooter .= $id; //slidy div stuff
    			$postfooter .= '" style="display:none; overflow:hidden; height:200px; text-align:right;">'; //slidy div stuff
    			$postfooter .= '<p>Some garbage here!</p>'; //slidy div stuff
    			$postfooter .= '</div>'; //slidy div stuff
    			$postfooter .= "</div><!-- .entry-utility -->\n";
    	    }
    
    	    // Put it on the screen
    	    echo apply_filters( 'thematic_postfooter', $postfooter ); // Filter to override default post footer
        } // end postfooter
    Posted 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.