• Das Erstellen neuer Accounts wurde ausgesetzt. Bei berechtigtem Interesse bitte Kontaktaufnahme über die üblichen Wege. Beste Grüße der Admin

[FRAGE] Listendarstellung zu Spaltendarstellung

exaxxio

New member
Guten Abend,

ich quäle mich gerade schon seit Stunden mit den folgenden Code-Zeilen.

Aktuell wird ein Datensatz pro Zeile ausgegeben, nun würde ich gerne, drei Datensätze je Zeile darstellen nur komme ich mit dem Code nicht zurecht.
Hat jemand vielleicht einen Tipp für mich. Das Testprojekt liegt gerade noch auf geld-verdienen-geld.de und es geht um die Darstellung der Neuzugänge auf der Startseite.

PHP:
<div id="Featured" class="blocks">
 <div  class="section">   
 <div id="wrap">
	
		<ul id="job-o" class="list clearfix">
			<!-- row 1 -->
			<li class="clearfix">
				<section class="left">
							<?php
			$args = jr_filter_form();
			query_posts($args);

			// call the main loop-job.php file
			get_template_part( 'loop', 'job-featured' );
		?>

		
		<?php wp_reset_query(); ?>
					
				</section>
			</li>
		</ul>
</div>
</div>
</div>

Vielen Dank schon einmal!
 
Zuletzt bearbeitet von einem Moderator:
... Aktuell wird ein Datensatz pro Zeile ausgegeben, nun würde ich gerne, drei Datensätze je Zeile darstellen ...
Laut deinem Code wird aber im Moment nur ein einziger Datensatz in einer einzigen Zeile ausgegeben. Ich sehe da nämlich keine Schleife o.ä.

Kannst du uns bitte nochmal mehr Infos zukommen lassen, z.B. wie sehen die Funktionen query_posts() und get_template_part() aus?
 
Auch ist der PHP-Code da komplett irrelevant. Wir müssen sehen, welches HTML im Browser ankommt und welches CSS du verwendest.

Aber ich könnte mir vorstellen, dass ein display: inline-block; mit einer geeigneten Breitenangabe eine Lösung sein könnte.
 
Der Code der geladenen wird ist der folgende:

PHP:
<?php
	$my_query = jr_get_featured_jobs();
	
	ob_start();
?>
<?php if ( $my_query && $my_query->have_posts() ) : $alt = 1; echo '<div class="section"><h2 class="pagetitle"><small class="rss"><a href="'.jr_get_featured_jobs_rss_url().'"><img src="'.get_bloginfo('template_url').'/images/feed.png" title="'.__('Featured Jobs RSS Feed',APP_TD).'" alt="'.__('Featured Jobs RSS Feed',APP_TD).'" /></a></small> '.__('Featured Jobs',APP_TD).'</h2><ol class="jobs">'; while ($my_query->have_posts()) : $my_query->the_post();

	$post_class = array( 'job', 'job-featured' );

	$found = true;

	$alt=$alt*-1; 

	if ($alt==1) $post_class[] = 'job-alt';
	$post_class[] = 'job-featured';
?>


 <li class="<?php echo implode(' ', $post_class); ?>">

<div id="logoso-listing">
 <?php if ( has_post_thumbnail()) : ?>
  <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail('thumbnail', array('class' => 'logoso')); ?>

   </a>
 <?php endif; ?>


 </div>
<?php appthemes_before_post_title( 'job_listing' ); ?>

<div id="titlo-featured">

<strong><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></strong> </div>

<div id="type-tag"><?php jr_get_custom_taxonomy($post->ID, 'job_type', 'jtype'); ?></div>
<div id="type-tag-prev"><?php jr_get_custom_taxonomy($post->ID, 'job_type', 'jtype'); ?></div>


					<div id="exc">
					<?php echo substr(get_the_excerpt(), 0,180); ?> ...
					</div>
					<?php appthemes_after_post_title( 'job_listing' ); ?>

                    <dt><?php _e('location', APP_TD); ?></dt>
                    
					
					
					
									<?php
    switch (get_option('enable_location_field')) {

                case "": ?>
               
                <?php break;

                case "Location by Google maps": ?>
           
		   <div  id="location"><strong><?php _e('Location:', APP_TD); ?></strong> <?php if ($address = get_post_meta($post->ID, 'geo_short_address', true)) echo wptexturize($address); else _e('Anywhere',APP_TD); ?> <?php echo wptexturize(get_post_meta($post->ID, 'geo_short_address_country', true)); ?></div>

                <?php break;

                case "Location by new taxonomy": ?>
                
				
<div  id="location"><strong><?php _e('Location:', APP_TD); ?></strong><?php if(get_the_term_list($post->ID, 'job_loc')) echo get_the_term_list($post->ID, 'job_loc', '', ' - ', '' ); else echo __('', APP_TD); ?></div>

               				
            
				
                <?php break;

               
            }
?>	

                    <dt><?php _e('Date', APP_TD); ?></dt>
                    <div id="date"><span class="year"> <?php echo date_i18n(__('d/M/Y',APP_TD), strtotime($post->post_date)); ?></span></div>
                   
					<div id="details-2"><strong><a href="<?php the_permalink(); ?>"><?php _e('Details', APP_TD); ?></a> </strong></div>
                    			
					
		<?php switch (get_option('enable_sharing')) {

                case "": ?>
               
                <?php break;

                case "Share to Facebook": ?>
             <div id="faceb"><a href="http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>" target="_blank" >Facebook</a></div>
			 

                <?php break;

                case "Share to Linkedin": ?>
   			
	<div id="linkedin"><a href="http://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink(); ?>&title=<?php the_title(); ?>&summary=<?php echo substr(get_the_excerpt(), 0,140); ?>" target="_blank" rel="nofollow">Linkedin</a></div>
   			
			
			
	 <?php break;

                case "Share to Twitter": ?>
   			
	<div id="twitter"><a href="http://www.twitter.com/home?status=<?php the_permalink(); ?>+<?php the_title(); ?> - <?php echo substr(get_the_excerpt(), 0,140); ?>" target="_blank" rel="nofollow">Twitter</a></div>		
			
			
                <?php break;
            
            }
?>				
			

              

            </li>
	
<?php 
	endwhile; 
		echo '</ol></div><!-- End section -->';
	endif; 
	
	// Prevents empty list
	if ( ! empty($found) ) {
		$output = ob_get_contents();
		ob_end_clean();
		echo $output;
	} else {
		ob_end_clean();
	}

Ich komme damit leider nicht weiter!
 
Wow, das ist mal ein unübersichtlicher Code ;)
Da tut sich selbst jeder Beautifier schwer...

PHP:
<?php
	$my_query = jr_get_featured_jobs();
	ob_start();
?>
<?php if ( $my_query && $my_query->
have_posts() ) : $alt = 1; echo '
<div class="section">
	<h2 class="pagetitle"><small class="rss"><a href="'.jr_get_featured_jobs_rss_url().'"><img src="'.get_bloginfo('template_url').'/images/feed.png" title="'.__('Featured Jobs RSS Feed',APP_TD).'" alt="'.__('Featured Jobs RSS Feed',APP_TD).'"/></a></small> '.__('Featured Jobs',APP_TD).'</h2>
	<ol class="jobs">
		'; while ($my_query->have_posts()) : $my_query->the_post(); $post_class = array( 'job', 'job-featured' ); $found = true; $alt=$alt*-1; if ($alt==1) $post_class[] = 'job-alt'; $post_class[] = 'job-featured'; ?>
		<li class="<?php echo implode(' ', $post_class); ?>">
		<div id="logoso-listing">
			<?php if ( has_post_thumbnail()) : ?>
			<a rel="nofollow" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>
			" > <?php the_post_thumbnail('thumbnail', array('class' =>
			 'logoso')); ?> </a>
			<?php endif; ?>
		</div>
		<?php appthemes_before_post_title( 'job_listing' ); ?>
		<div id="titlo-featured">
			<strong><a rel="nofollow" href="<?php the_permalink(); ?>"><?php the_title(); ?>
			</a></strong>
		</div>
		<div id="type-tag">
<?php jr_get_custom_taxonomy($post->
			ID, 'job_type', 'jtype'); ?>
		</div>
		<div id="type-tag-prev">
<?php jr_get_custom_taxonomy($post->
			ID, 'job_type', 'jtype'); ?>
		</div>
		<div id="exc">
			<?php echo substr(get_the_excerpt(), 0,180); ?>
			 ...
		</div>
		<?php appthemes_after_post_title( 'job_listing' ); ?>
		<dt><?php _e('location', APP_TD); ?>
		</dt>
		<?php
    switch (get_option('enable_location_field')) {
                case "": ?>
		<?php break;
                case "Location by Google maps": ?>
		<div id="location">
			<strong><?php _e('Location:', APP_TD); ?>
			</strong><?php if ($address = get_post_meta($post->
			ID, 'geo_short_address', true)) echo wptexturize($address); else _e('Anywhere',APP_TD); ?> <?php echo wptexturize(get_post_meta($post->
			ID, 'geo_short_address_country', true)); ?>
		</div>
		<?php break;
                case "Location by new taxonomy": ?>
		<div id="location">
			<strong><?php _e('Location:', APP_TD); ?>
			</strong><?php if(get_the_term_list($post->
			ID, 'job_loc')) echo get_the_term_list($post->ID, 'job_loc', '', ' - ', '' ); else echo __('', APP_TD); ?>
		</div>
		<?php break;
            }
?>
		<dt><?php _e('Date', APP_TD); ?>
		</dt>
		<div id="date">
			<span class="year"><?php echo date_i18n(__('d/M/Y',APP_TD), strtotime($post->
			post_date)); ?></span>
		</div>
		<div id="details-2">
			<strong><a rel="nofollow" href="<?php the_permalink(); ?>"><?php _e('Details', APP_TD); ?>
			</a></strong>
		</div>
		<?php switch (get_option('enable_sharing')) {
                case "": ?>
		<?php break;
                case "Share to Facebook": ?>
		<div id="faceb">
			<a onclick="_gaq.push(['_trackEvent', 'Outgoing', 'www.facebook.com', '/sharer.php?u=<?php the_permalink(']);" href="http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>" target="_blank" >Facebook</a>
		</div>
		<?php break;
                case "Share to Linkedin": ?>
		<div id="linkedin">
			<a onclick="_gaq.push(['_trackEvent', 'Outgoing', 'www.linkedin.com', '/shareArticle?mini=true&url=<?php the_permalink(']);" href="http://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink(); ?>&title=<?php the_title(); ?>
			&summary=<?php echo substr(get_the_excerpt(), 0,140); ?>
			" target="_blank" rel="nofollow">Linkedin</a>
		</div>
		<?php break;
                case "Share to Twitter": ?>
		<div id="twitter">
			<a onclick="_gaq.push(['_trackEvent', 'Outgoing', 'www.twitter.com', '/home?status=<?php the_permalink(']);" href="http://www.twitter.com/home?status=<?php the_permalink(); ?>+<?php the_title(); ?>
			 - <?php echo substr(get_the_excerpt(), 0,140); ?>
			" target="_blank" rel="nofollow">Twitter</a>
		</div>
		<?php break;
            }
?>
		</li>
		<?php 
	endwhile; 
		echo '</ol>
	</div>
	<!-- End section -->
';
	endif; 
	// Prevents empty list
	if ( ! empty($found) ) {
		$output = ob_get_contents();
		ob_end_clean();
		echo $output;
	} else {
		ob_end_clean();
	}
 
Wie gesagt,


Zurzeit werden die Daten Zeile für Zeile dargestellt.
Ich würde gerne 3 Datensätze je Zeile ausgeben, nur kapiere ich die Ausgwertung der Daten im Code nicht, es müsste doch sowas wie eine Schleife geben, oder nicht?!!
 
Zeig' uns doch wirklich mal den HTML-Quelltext, der im Browser ankommt und nicht das PHP-Zeugs.

Aber prinzipiell könnte das HTML/CSS so aussehen:
Code:
<!DOCTYPE html>

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Fenstertitel</title>
<script type="text/javascript"></script>
<style type="text/css">
#content {
	position: relative;
	word-spacing: -1em;
	border: 1px solid black;
}
#content * {
	word-spacing: initial;
}
.element {
	display: inline-block;
	background-color: yellow;
	width: 33.3333%;
	margin-bottom: 5px;
}
</style>
</head>
<body>
<div id="content">
	<span class="element">1</span>
	<span class="element">2</span>
	<span class="element">3</span>
	<span class="element">4</span>
	<span class="element">5</span>
	<span class="element">6</span>
	<span class="element">7</span>
	<span class="element">8</span>
	<span class="element">9</span>
	<span class="element">10</span>
	<span class="element">11</span>
</div>
</body>
</html>
 
Der geladene Code ist folgender:

HTML:
<!-- featured jobs -->	
<div id="Featured" class="blocks">
 <div  class="section">   
 <div id="wrap">
	
		<ul id="job-o" class="list clearfix">
			<!-- row 1 -->
			<li class="clearfix">
				<section class="left">
							<div class="section"><h2 class="pagetitle"><small class="rss"><a href="http://geld-vergleich-geld.de/feed/?rss_featured=1"><img src="http://geld-vergleich-geld.de/wp-content/themes/jobroller/images/feed.png" title="Hervorgehobene Stellenanzeigen im RSS Feed" alt="Hervorgehobene Stellenanzeigen im RSS Feed" /></a></small> Hervorgehobene Stellen</h2><ol class="jobs">

 <li class="job job-featured job-featured">

<div id="logoso-listing">
   <a href="http://geld-vergleich-geld.de/sex-anzeigen/thai-thai/" title="Thai Thai" >
<img width="150" height="150" src="http://geld-vergleich-geld.de/wp-content/uploads/2014/02/stock-photo-21774351-beautiful-brunette-woman-150x150.jpg" class="logoso wp-post-image" alt="stock-photo-21774351-beautiful-brunette-woman" />
   </a>
 

 </div>

<div id="titlo-featured">

<strong><a href="http://geld-vergleich-geld.de/sex-anzeigen/thai-thai/">Thai Thai</a></strong> </div>
<div id="type-tag"><span class="jtype">Anzeige</span></div>
<div id="type-tag-prev"><span class="jtype">Anzeige</span></div>

					<div id="exc">
					Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam e ...
					</div>
					
                    <dt>Ort</dt>									           
		   <div  id="location"><strong>Ort: </strong> Dachau Bayern, Deutschland</div>

                    <dt>Datum</dt>
                    <div id="date"><span class="year"> 25/Feb/2014</span></div>
                   
		<div id="details-2"><strong><a href="http://geld-vergleich-geld.de/sex-anzeigen/thai-thai/">Details</a> </strong></div>
                    			
<!-- Original					
		             <div id="faceb"><a href="http://www.facebook.com/sharer.php?u=http://geld-vergleich-geld.de/sex-anzeigen/thai-thai/" target="_blank" >Facebook</a></div>
			 			
-->
              

            </li>
 
Zurück
Oben