'I need to use a boolean column from my database that is set a 1 or 0 to change the look of one of my articles in my web page
Sorry if the title is a little confusing was trying not to make it too long. I am currently in school and my teacher has tasked us with this "Add a boolean column to the news table called “importance.” In that column set the second story to
True (1) and the other two to False (0). When the all-news story page is loaded, detect which story is
important, and add some styling to that story to show it’s “more important” than the others. This can be
as simple as adding a bold or colored title, or putting a star next to the title, or something similar. If you
do this correctly, you should be able to set any or all stories as important in the DB and when the
all-news stories page is loaded it will update correctly automatically." I have tried to figure this out for like 4 days now I was easily able to create the boolean column I just dont really know how to get it to affect my web page. We have to do this in CodeIgniter while making sure to have proper division of concerns we have been instructed that the only division of concerns violations we can do are "You may use
in your JS to help style. For example, var str = ‘hello<br>’
;
You may use the PHP print tag in your HTML. For example, <?= $variable ?>
"
Here is the code I currently have:
Controller
defined('BASEPATH') OR exit('Forbidden');
class Tales extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('Tales_model');
$this->load->helper('url_helper');
}
public function index()
{
$tales['tales'] = $this->Tales_model->get_tales();
$data['tales'] = $this->parser->parse('templates/tales_outline', $tales, true);
$this->load->view('templates/header');
$this->load->view('tales/tales_main', $data);
$this->load->view('templates/footer');
}
public function view($slug = NULL)
{
$tale = $this->Tales_model->get_tales($slug);
$data['tale'] = $this->parser->parse('templates/tale_outline', $tale, true);
$this->load->view('templates/header_back1');
$this->load->view('tales/tales_solo', $data);
$this->load->view('templates/footer');
}
}
tales_outline
<article>
<div>
<hr>
<h3>{title}</h3><br>
<img class="art_img" src="../../../assets/images/{slug}.jpeg" alt="{slug} image">
<br>
<p>{text}</p><br>
<br>
<p><a class="button" id="alone" href="/index.php/tales/{slug}">View Article</a></p><br>
<br>
</div>
</article>
{/tales}
any help offered is appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|