用PHP过滤投资组合

时间:2015-03-28 16:43:06

标签: php wordpress twitter-bootstrap advanced-custom-fields

我正在投资组合页面,因为我不想重复代码,所以我的所有投资组合都有1个数据库。 我有2个类别,工作和空闲时间。两个类别都有自己的页面。 在这两个类别下,我有几个子类别。 工作有荷兰,英国,德国,Freetime有比利时,法国和西班牙。

我如何确保当我不从Freetime中选择任何子类别时,投资组合项目不会显示在工作中的所有投资组合项目下,反之亦然? (我希望我的问题很清楚)

这是我有的代码,我在那里检索组合数据库并使用foreach循环遍历所有项目:

        <div id="container-portfolio" class="containerp">   
            <div id="effect-2" class="effects clearfix">            
                        <?php
                    $portfolio_items = get_field('portfolio_items',165);
                        if($portfolio_items):                   
                            foreach($portfolio_items as $index => $item) :                                                  
                            $category_work = $item['category_work'];                                                            
                            $image = $item['image'];                                
                            $title = $item['title'];                                
                            $description = $item['description'];
                            $short_description = $item['short_description'];                            
                            $website = $item['website'];
                            $why = $item['why'];
                            $quote = $item['quote'];
                            $quotename = $item['quotename'];    
                            $category_freetime = $item['category_freetime'];

                    ?>  

                <div class="mix <?php print implode(' ', $category_work); ?>">                                  
                    <div class="img">                                      
                         <img  src="<?php print $image; ?>" alt="<?php print $title; ?>" width="175" height="175">                                     
                          <div class="overlay">                                        
                             <a href="#"  data-toggle="modal" data-target="#<?php print $title; ?>" 
                                class="expand"><?php echo __('More Info..', 'info'); ?></a>                                         
                                <a class="close-overlay hidden">x</a>                                       
                          </div>                                   
                     </div>                                 
                 </div>     

              <div class="modal fade" id="<?php print $title; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >                                
                     <div class="modal-dialog">                                 
                        <div class="modal-content">                                   
                            <div class="modal-header">                                     
                                 <button type="button" class="close" data-dismiss="modal">
                                    <span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
                                 </button>                                      

                            </div>                                    
                            <div class="modal-body" style="text-align:center;">                                       
                                <img  src="<?php print $image; ?>" alt="<?php print $title; ?>" width="175" height="175">                                         
                                <h1><?php print $title; ?></h1> 
                                <p class="subTitle"><?php print $short_description ?></p>   
                                <p class="description"><?php print $description; ?></p>
                                <p class="why">Why we love it</p>
                                <p class="whyText"><?php print $why; ?></p>                                                                                                                                      
                                <hr class="portfolio_hr">
                                <p class="quoteText">&ldquo;<?php print $quote; ?>&rdquo;</p>
                                <p>&ndash;&nbsp;<?php print $quotename; ?></p>                           
                                <hr class="portfolio_hr">   
                                <p><a href="http://<?php print $website;  ?>" target="_blank">http://<?php print $website;  ?></a></p>                                                        
                            </div>                              
                            </div>                               
                        </div>                          
                    </div>                                              
                    <?php                   
                    endforeach; endif; ?>nter code here

如果您需要我提供更多信息,请与我们联系。

0 个答案:

没有答案