Support

Account

Home Forums General Issues Error with If and Else If Statements

Unread

Error with If and Else If Statements

  • Hi,

    Following on from my previous post I’ve attempted to set out my If and Else If statement further but to no avail. I’ve tried multiple versions but have gotten nowhere. the code is –

    <?php
    
    class td_module_9 extends td_module {
    
        function __construct($post, $module_atts = array()) {
            //run the parrent constructor
            parent::__construct($post, $module_atts);
        }
    
        function render() {
            ob_start();
            $title_length = $this->get_shortcode_att('m9_tl');
            $modified_date = $this->get_shortcode_att('show_modified_date');
            
            ?>
            
            <div class ="<?php echo $this->get_module_classes();?>">
    		
            	<div class ="item-details">
            
                	<div ="news_headline"><a target="_blank" href="<?php the_field('title_link', $this->post->ID); ?>" rel="bookmark" title="<?php echo get_the_title( $this->post->ID );//$title; ?>"><?php echo get_the_title( $this-					>post->ID ); //$title; ?></a></div> 
                                   
                    	<div class="td-module-meta-info">
                        
    <?php
      
    		$hb1 = in_category(array('News','Features','Tech'), $this->post->ID);
    		$hb2 = in_category( array('Research'), $this->post->ID );
    		$hb3 = has_tag(array( 'aged care', 'anxiety/stress', 'autism', 'cognitive', 'Dementia', "Parkinson's", 'sleep' , 'well-being' ), $this->post->ID);
    
    if ( $hb1 )
    
    { 
      
      		$link = get_field('media_outlet_url', $this->post->ID);
    		$media = get_field ('media_outlet', $this->post->ID);
    		$country = get_field ('country', $this->post->ID);
    		$publicationdate = get_field ('publication_date', $this->post->ID);
            $abstract_excerpt = get_post_field('post_content', $this->post->ID);
        
                    		<div class="media_date" style="margin-top:5px;">    
                        		<span class="td-post-author-name"><a target="_blank" href="<?php echo $link; ?>"><?php echo $media; ?></a> <span>-</span> </span>
                        		<span class="td-post-date"><time class="entry-date updated td-module-date"><?php echo $publicationdate; ?></time></span>
                    		</div>
                            <div class="td-post-content" style=" margin-top: 5px; padding: 0; "><?php echo $abstract_excerpt; ?> </div>
                            
                       </div>
               </div>
      
     }
     
     else if ( $hb2 && $hb3 )
    
    { 
      
      		$media = get_field ('media_outlet', $this->post->ID);
    		$publicationdate = get_field ('publication_date', $this->post->ID);
        
                    		<div class="media_date" style="margin-top:5px;">    
                        		<span class="td-post-author-name"><?php echo $media; ?> <span>-</span> </span>
                        		<span class="td-post-date"><time class="entry-date updated td-module-date"><?php echo $publicationdate; ?></time></span>
                    		</div>
                            <div class="td-post-content" style=" margin-top: 5px; padding: 0; "><echo $this->get_the_tags();?> </div>
                            
                       </div>
               </div>
      
     }
      
     ?>
     
    </div>
              
                
    
    	        <?php echo $this->get_quotes_on_blocks();?>
    
            </div>
    
            <?php return ob_get_clean();
        }
    }
      
      

    Any, and all help, would be hugely appreciated. I just can’t seem to find the error and would welcome a fresh set if eyes.

    Thanks.

    Best

    Gary

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.