我已经粘贴了我的数据库的两个屏幕快照,以及我希望我的网页看起来如何。即时通讯试图做到这一点,但没有得到解决问题的方法 我已将所有图像存储在文件夹中,并且还将图像路径存储在数据库中,现在我想以一种方式获取图像,即当我单击所有作品时,它应该显示所有图像,但是当我单击创意,摄影或网络时像这样的开发,那么它应该只显示与存储在数据库中的类相关的图像,类型为列。或者,例如,如果我单击说创意,那么它应该像这样显示第二,第三,第五和第八。我真的不知道该怎么做。请我真的需要帮助
//-----controller------
public function portfolio()
{
$this->load->helper('url');
$this->load->view('header');
$data['results'] = $this->Contact_model->getAllRecords3();
$this->load->view('portfolio',$data);
$this->load->view('footer');
}
//--------model-----
function getAllRecords3()
{
return $this->db->get('portfolio1')->result();
}
//-------view---------
<section id="portfolio">
<div class="container">
<div class="center">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt</p>
</div>
<ul class="portfolio-filter text-center">
<li><a class="btn btn-default active" href="#" data-filter="*">All Works</a></li>
<li><a class="btn btn-default" href="#" data-filter=".bootstrap">Creative</a></li>
<li><a class="btn btn-default" href="#" data-filter=".html">Photography</a></li>
<li><a class="btn btn-default" href="#" data-filter=".wordpress">Web Development</a></li>
</ul>
<!--/#portfolio-filter-->
</div>
<div class="container">
<div class="">
<div class="portfolio-items">
<?php
if( !empty($results) ) {
foreach($results as $row) {?>
<div class="portfolio-item apps joomla col-xs-12 col-sm-4 col-md-3">
<div class="recent-work-wrap">
<img class="img-responsive" src="<?php echo base_url('uploads/'.$row->filename);?>" alt="">
<div class="overlay">
<div class="recent-work-inner">
<h3><a href="#"><?php echo $row->first_content; ?></a></h3>
<p><?php echo $row->second_content; ?></p>
<a class="preview" href="<?php echo base_url('uploads/'.$row->filename);?>" rel="prettyPhoto"><i class="fa fa-eye"></i> View</a>
</div>
</div>
</div>
</div>
<?php
} ?>
<?php }
?>
</div>
</div>
</div>
</section>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="<?php echo base_url(); ?>js/jquery-2.1.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="<?php echo base_url(); ?>js/bootstrap.min.js"></script>
<script src="<?php echo base_url(); ?>js/jquery.prettyPhoto.js"></script>
<script src="<?php echo base_url(); ?>js/jquery.isotope.min.js"></script>
<script src="<?php echo base_url(); ?>js/wow.min.js"></script>
<script src="<?php echo base_url(); ?>js/functions.js"></script>
答案 0 :(得分:1)
请尝试以下解决方案。
您错过了在div中添加动态类的动态类,例如应用和 joomla
<div class="portfolio-item apps joomla col-xs-12 col-sm-4 col-md-3">
在上面的类中添加了您现有的代码
<?php
foreach($results as $row) {
//code for getting dynamic class names from db
$class = explode(",.", $row->type);
$gettypes = implode(" ", $class);
?>
<div class="portfolio-item <?php echo $gettypes;?> col-xs-12 col-sm-4 col-md-3">
希望这项工作!
答案 1 :(得分:0)
U已包含jquery.isotope.min.js库,您需要遵循以下文档
$grid.isotope({ filter: '.transition' })
也更改为以下查看代码
<div class="portfolio-item <?php echo $gettypes;?> col-xs-12 col-sm-4 col-md-3">