php Двациклавнутри1гослайдераforeachinforобверткадлядвухцикловслайдыдлядвухциклов

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Двациклавнутри1гослайдераforeachinforобверткадлядвухцикловслайдыдлядвухциклов相关的知识,希望对你有一定的参考价值。

<?php
	$clients_title = get_sub_field( 'clients_title' );
	$clients = get_sub_field( 'clients' );

	$s_name = get_sub_field( 's_name' );
	$scroll_title = get_sub_field( 'scroll_title' );
	$scroll_s_name = get_sub_field( 'scroll_s_name' );
	$scroll_up = get_sub_field( 'scroll_up' );
	$clients_per_slide = 10;

	if( $clients ): $clients_count = count( $clients );
?>

	<section class="section section-clients" <?php if( $s_name ): ?>id="<?php echo $s_name; ?>"<?php endif; ?>>

		<?php if( $clients_title ): ?><header><h1><?php echo $clients_title; ?></h1></header><?php endif; ?>

		<div class="posts-gallery">
			<div class="mask">
				<div class="slideset">

					<?php if ( $clients_count > $clients_per_slide and $clients_count%$clients_per_slide != 0 ): $slide_count = ceil( $clients_count/$clients_per_slide ); ?>

						<?php for( $i = 1; $i <= $slide_count; $i++ ): ?>
							<div class="tabs-holder vertical-scroll-area slide">

								<div class="tab-content">
								    <?php
									    if ( $i > 1) {
									    	$counter_start = $clients_per_slide*($i-1);
									    }else{
									    	$counter_start = 0;
									    }

									    $counter = 0;
									    $innercounter = 0;

								    	foreach( $clients as $client ): ++$counter;

								    		if( $counter <= $clients_per_slide and $counter_start == 0 or $counter > $counter_start ):

								    			++$innercounter;

									    		$client_title = $client->post_title;

									    		if ( has_post_thumbnail( $client->ID ) )
									    		{
									    			$client_icon = wp_get_attachment_image_src( get_post_thumbnail_id( $client->ID ), 'full' );
									    		}

												$client_text = apply_filters( 'the_content', $client->post_content );
												$client_btn_text = get_field( 'client_btn_text', $client->ID );
												$client_btn_link = get_field( 'client_btn_link', $client->ID );
												$client_color = get_field( 'client_color', $client->ID );
								    ?>

											    	<div id="<?php echo strtolower( preg_replace("([^a-zA-Z])", "", $client_title) ); ?>" class="tab <?php echo $client_color; ?>">
														<?php if( $client_title ): ?><div class="heading"><i class="fa fa-angle-left" aria-hidden="true"></i><h2><?php echo $client_title; ?></h2></div><?php endif; ?>
														<?php if( $client_icon ): ?><img src="<?php echo $client_icon[0]; ?>" alt="<?php echo $client_title; ?>" /><?php endif; ?>
														<?php echo $client_text; ?>
														<?php if( $client_btn_text and $client_btn_link ): ?><a href="<?php echo $client_btn_link; ?>" class="btn"><?php echo $client_btn_text; ?></a><?php endif; ?>
													</div>

								    <?php endif; if( $innercounter == $clients_per_slide ){ break; } endforeach; ?>
							    </div>

							    <div class="tabset scroll-wrap">
									<?php
										if ( $i > 1) {
									    	$counter_start = $clients_per_slide*($i-1);
									    }else{
									    	$counter_start = 0;
									    }

									    $counter = 0;
									    $innercounter = 0;

								    	foreach( $clients as $client ): ++$counter;
								    		if( $counter <= $clients_per_slide and $counter_start == 0 or $counter > $counter_start ):

								    			++$innercounter;

									    		$client_title = $client->post_title;

									    		if ( has_post_thumbnail( $client->ID ) )
									    		{
									    			$client_icon = wp_get_attachment_image_src( get_post_thumbnail_id( $client->ID ), 'full' );
									    		}

												$client_text = apply_filters( 'get_the_content', $client->post_content );
												$client_btn_text = get_field( 'client_btn_text', $client->ID );
												$client_btn_link = get_field( 'client_btn_link', $client->ID );
												$client_color = get_field( 'client_color', $client->ID );
								    ?>

											    	<div class="box <?php echo $client_color; ?>">
														<?php if( $client_icon ): ?><a <?php if( $s_name ): ?>href="#<?php echo $s_name; ?>"<?php endif; ?> data-tab="#<?php echo strtolower( preg_replace("([^a-zA-Z])", "", $client_title) ); ?>"><img src="<?php echo $client_icon[0]; ?>" alt="<?php echo $client_title; ?>" /></a><?php endif; ?>
														<div class="info">
															<?php if( $client_title ): ?><h2><?php echo $client_title; ?></h2><?php endif; ?>
															<?php echo $client_text; ?>
															<?php if( $client_btn_text and $client_btn_link ): ?><a href="<?php echo $client_btn_link; ?>" class="btn"><?php echo $client_btn_text; ?></a><?php endif; ?>
														</div>
													</div>

								    <?php endif; if( $innercounter == $clients_per_slide ){ break; } endforeach; ?>
								</div>

							</div>
						<?php endfor; ?>

					<?php else: ?>

						<div class="tabs-holder vertical-scroll-area slide">

							<div class="tab-content">
							    <?php
							    	$counter = 0;

							    	foreach( $clients as $client ): ++$counter;
							    		$client_title = $client->post_title;

							    		if ( has_post_thumbnail( $client->ID ) )
							    		{
							    			$client_icon = wp_get_attachment_image_src( get_post_thumbnail_id( $client->ID ), 'full' );
							    		}

										$client_text = apply_filters( 'the_content', $client->post_content );
										$client_btn_text = get_field( 'client_btn_text', $client->ID );
										$client_btn_link = get_field( 'client_btn_link', $client->ID );
										$client_color = get_field( 'client_color', $client->ID );
							    ?>

							    	<div id="<?php echo strtolower( preg_replace("([^a-zA-Z])", "", $client_title) ); ?>" class="tab <?php echo $client_color; ?>">
										<?php if( $client_title ): ?><div class="heading"><i class="fa fa-angle-left" aria-hidden="true"></i><h2><?php echo $client_title; ?></h2></div><?php endif; ?>
										<?php if( $client_icon ): ?><img src="<?php echo $client_icon[0]; ?>" alt="<?php echo $client_title; ?>" /><?php endif; ?>
										<?php echo $client_text; ?>
										<?php if( $client_btn_text and $client_btn_link ): ?><a href="<?php echo $client_btn_link; ?>" class="btn"><?php echo $client_btn_text; ?></a><?php endif; ?>
									</div>

							    <?php endforeach; ?>
						    </div>

						    <div class="tabset scroll-wrap">
								<?php
									$counter = 0;

							    	foreach( $clients as $client ): ++$counter;
							    		$client_title = $client->post_title;

							    		if ( has_post_thumbnail( $client->ID ) )
							    		{
							    			$client_icon = wp_get_attachment_image_src( get_post_thumbnail_id( $client->ID ), 'full' );
							    		}

										$client_text = apply_filters( 'get_the_content', $client->post_content );
										$client_btn_text = get_field( 'client_btn_text', $client->ID );
										$client_btn_link = get_field( 'client_btn_link', $client->ID );
										$client_color = get_field( 'client_color', $client->ID );
							    ?>

							    	<div class="box <?php echo $client_color; ?>">
										<?php if( $client_icon ): ?><a <?php if( $s_name ): ?>href="#<?php echo $s_name; ?>"<?php endif; ?> data-tab="#<?php echo strtolower( preg_replace("([^a-zA-Z])", "", $client_title) ); ?>"><img src="<?php echo $client_icon[0]; ?>" alt="<?php echo $client_title; ?>" /></a><?php endif; ?>
										<div class="info">
											<?php if( $client_title ): ?><h2><?php echo $client_title; ?></h2><?php endif; ?>
											<?php echo $client_text; ?>
											<?php if( $client_btn_text and $client_btn_link ): ?><a href="<?php echo $client_btn_link; ?>" class="btn"><?php echo $client_btn_text; ?></a><?php endif; ?>
										</div>
									</div>

							    <?php endforeach; ?>
							</div>

						</div>

					<?php endif; ?>

				</div>
			</div>
			<?php if( $clients_count > $clients_per_slide ): ?><div class="pagination"><!-- pagination generated here --></div><?php endif; ?>
		</div>

		<?php if( $scroll_title and $scroll_s_name ): ?>
			<footer><a href="#<?php echo $scroll_s_name; ?>"><?php echo $scroll_title; ?> <i class="fa <?php if( $scroll_up ): ?>fa-angle-up<?php else: ?>fa-angle-down<?php endif; ?>" aria-hidden="true"></i></a></footer>
			<span class="scroll-down"></span>
		<?php endif; ?>
	</section>

<?php endif; ?>

以上是关于php Двациклавнутри1гослайдераforeachinforобверткадлядвухцикловслайдыдлядвухциклов的主要内容,如果未能解决你的问题,请参考以下文章

php Проверкаестьлифильтрынавигацияпродуктывтекущейкатегории

Erlangе демо

php Вывестиминимальнуюценуторговыхпредложенийвсписоктоваров

php Выгрузкафайловизинфоблоковсогласноструктуреразделов

php ОставляетуказанныегруппыполейACFнастраницеуказанныхтерминоввадминке,анаостальныхудаляет。

php Сортировкаассоциативногомассивавпорядкеуказанноммассивомключей。