Bonjour,

J'ai la portion de code ci-dessous qui permet l'affichage d'un widget.

Pour le "echo $before_title", je souhaiterais mettre en place une condition d'affichage de la façon suivante :
si $title est vide, alors il doit y avoir un echo '<div class="widget-top" style="border-bottom: none !important"><h4>';
sinon affichage de l'echo $before_title.

Comment puis-je faire ?

Merci par avance pour votre aide.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function widget( $args, $instance ) {
		extract( $args );
 
		$title = apply_filters('widget_title', $instance['posts_list_title'] );
		$no_of_posts = $instance['no_of_posts'];
		$posts_order = $instance['posts_order'];
		$thumb = $instance['thumb'];
 
		echo $before_widget;
   echo $before_title;
 
			echo $title ; ?>
		<?php echo $after_title; ?>
				<ul>
					<?php
					if( $posts_order == 'popular' )
						tie_popular_posts($no_of_posts , $thumb);
 
					elseif( $posts_order == 'random' )
						tie_random_posts($no_of_posts , $thumb);
 
					elseif( $posts_order == 'viewed' )
						tie_most_viewed_posts($no_of_posts , $thumb);
 
					elseif( $posts_order == 'best' )
						tie_best_reviews_posts($no_of_posts , $thumb);
 
					else
						tie_last_posts($no_of_posts , $thumb)?>	
				</ul>
		<div class="clear"></div>
	<?php 
		echo $after_widget;
	}