Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Sintassi if

  1. #1

    Sintassi if

    Ciao a tutti.
    Ho modificato un file in php ma ora mi ritrovo a combattere con la sintassi degli if ().
    Questo codice mi genera 2 tipi diversi di struttura in <div> ma me li visualizza tutti e 2 contemporaneamente, mentre dovrebbe visualizzarmi una struttura quando è attiva e l'altra non caricarla per niente.
    Ho applicato degli if ed elseif ma senza successo.
    Dove sbaglio?
    Di seguito riporto il codice

    codice:
    <?php if (get_option('thestyle_blog_style') == 'false') { ?>
    
    
    
    	
    	<?php $biglayout = ( (bool) get_post_meta($post->ID,'et_bigpost',true) ) ? true : false;
    		$thumb = '';
    		$width = $biglayout ? 466 : 222;
    		$height = 180;
    		$classtext = '';
    		$titletext = get_the_title();
    		
    		$thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext);
    		$thumb = $thumbnail["thumb"]; ?>
    		
    	<div class="entry <?php if ($biglayout) echo('big'); else echo('small');?>">
    		<div class="thumbnail">
    			<a href="<?php the_permalink(); ?>">
    				<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>
    				<span class="overlay"></span>
    			</a>
    			<div class="category"><?php the_category(); ?></div>
    			<span class="month"><?php the_time('M'); ?><span class="date"><?php the_time('d'); ?></span></span>
    		</div> 	
    		<h2 class="title"><?php if ($biglayout) truncate_title(50); else truncate_title(20); ?></h2>
    		<p class="postinfo"><?php _e('posted by','TheStyle'); ?> <?php the_author_posts_link(); ?></p>
    		<div class="entry-content">
    			<div class="bottom-bg">
    				<div class="excerpt">
    					
    
    <?php if ($biglayout) truncate_post(650); else truncate_post(295); ?> </p>
    					<div class="textright">
    						<span>&raquo;</span>&raquo;
    					</div>
    				</div>
    			</div>
    		</div>
    	</div>
    	
    	
    		
    	
    	
    	
    		
    		<?php $photolayout = ( (bool) get_post_meta($post->ID,'et_photopost',true) ) ? true : false;
    		$thumb = '';
    		$width = $photolayout ? 466 : 222;
    		$height = $photolayout ? 554 : 180;
    		$classtext = '';
    		$titletext = get_the_title();
    		
    		$thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext);
    		$thumb = $thumbnail["thumb"]; ?>
    		
    	<div class="entry <?php if ($photolayout) echo('photo'); else echo('small');?>">
    		<div class="thumbnail">
    			<a href="<?php the_permalink(); ?>">
    				<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>
    				<span class="overlay"></span>
    			</a>
    			<div class="category"><?php the_category(); ?></div>
    		</div> 	
    		<h2 class="title"><?php if ($photolayout) truncate_title(50); else truncate_title(20); ?></h2>
    		<p class="postinfo"><?php _e('posted by','TheStyle'); ?> <?php the_author_posts_link(); ?></p>
    		<div class="entry-content">
    			<div class="bottom-bg">
    			</div>
    		</div>
    	</div>
    	
    	
    	
    	
    	
    	
    	
    <?php } 
    
    
    
    
    else { ?>
    
    	<div class="post">
    		<div class="post-content clearfix">			
    			<div class="post-text">
    				<h2 class="blog-title"><?php the_title(); ?></h2>
    				
    				<?php if (get_option('thestyle_postinfo1') <> '') { ?>
    					<p class="post-meta">
    						<?php _e('Posted','TheStyle'); ?> <?php if (in_array('author', get_option('thestyle_postinfo1'))) { ?> <?php _e('by','TheStyle'); ?> <?php the_author_posts_link(); ?><?php }; ?><?php if (in_array('date', get_option('thestyle_postinfo1'))) { ?> <?php _e('on','TheStyle'); ?> <?php the_time(get_option('thestyle_date_format')) ?><?php }; ?><?php if (in_array('categories', get_option('thestyle_postinfo1'))) { ?> <?php _e('in','TheStyle'); ?> <?php the_category(', ') ?><?php }; ?><?php if (in_array('comments', get_option('thestyle_postinfo1'))) { ?> | <?php comments_popup_link(__('0 comments','TheStyle'), __('1 comment','TheStyle'), '% '.__('comments','TheStyle')); ?><?php }; ?>
    					</p>
    				<?php }; ?>
    				
    				<div class="hr"></div>
    				
    				<?php the_content(); ?>
    				
    				<?php wp_link_pages(array('before' => '
    
    '.__('Pages','TheStyle').': ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    				<?php edit_post_link(__('Edit this page','TheStyle')); ?>
    			</div> 
    			
    			<div class="info-panel">
    				<?php include(TEMPLATEPATH . '/includes/infopanel.php'); ?>
    			</div> 
    		</div> 
    	</div>
    	
    <?php } ?>
    - TRZ -

  2. #2
    ciao, vorrei sapere ma

    get_option('thestyle_blog_style') == 'false'

    ti da solo come valore false, oppure ti da anche altri valori, tipo true, none ecc

    fammi sapere


    comunque l' else cambialo in



    elseif (get_option('thestyle_blog_style') != 'false')

    vedi se funziona

  3. #3
    Grazie dell'aiuto teck2010, ma niente non funziona.
    Mi genera errore.
    get_option('thestyle_blog_style') == 'false'
    mi da come valore anche true dalle impostazioni del backend che ho, ma per quello che serve a me deve rimanere flase.
    Il problema ce l'ho quando inizia il codice che definisce BIG POST e PHOTO POST.
    Ho due check box nel backend che fa vedere una il BIG POST e l'altra il PHOTO POST.
    Ora, il problema è che quando vado nel frontend se seleziono la checkbox PHOTO POST mi fa vedere anche BIG POST.
    Dovrei aggiungere un else if per BIG POST e PHOTO POST.
    Per rendere meglio ecco il risultato che ho:

    - TRZ -

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.