Welcome Guest, Not a member yet? Register   Sign In
Different Views for Articles
#1

How would I go about having different views for an article in Code Igniter.
For example I have one Index for all articles and I also have a view. But what If I want to have say 10 pictures for one article and only three for another?
So my view is:



Code:
<div id="wrapper">    
<div id="main-wrapper" class="col-md-10 pull-right">
 <div id="main">  
  <div class="col-md-9">
   <div id="sec#" class="">
       <h2><?= $article['title']?></h2>
    <img border="0" src="<?= assetUrl() ?>img/article/<?= $article['image']?>">
    <h6>Date: <?= $article['date']?></h6>
    <h6>Author: <?= $article['author']?></h6>
    <br>
    <p><?= $article['body']?></p>
   </div>
  </div>
 </div><!--/right-->
</div><!--Main wrapper-->
</div><!--Wrapper-->


All the articles look the same. But what if I want to have pictures within the body of the article? And what if the number of pictures are different for each article.

I'm struggling with this, because all the articles look the same. And depending on the text, it would be nice to render pictures on different parts of the body.

Also, I've been adding HTML tags in the longtext and I save them in the database. Isn't this dangerous? I'm sure there must be a better way of doing this. But if I don't put any
tags, the body just displays as one big blob of text.

Thanks
Reply
#2

Pass the images through the $data, you can then use count() to get the count of images and loop through them using a foreach loop.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

Yes, but the I won't have any control of where in the article the pictures render.
Reply
#4

For Bootstrap you should be using the image responsive class.

You can load other views within a view so that would be up to you
where you want to put them, just do a flag check etc;
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB