[eluser]atlanta[/eluser]
story.php (Controller)
Code:
class Story extends Controller {
var $categories;
function Story()
{
parent::Controller();
$this->load->model('story/stories_model');
}
function id ()
{
$query = $this->stories_model->get_story_info($this->uri->segment(3));
if ($query->num_rows() > 0)
{
$data['info'] = $query->row_array();
}
else
{
redirect('story/');
}
$data['title'] = $data['info']['title'];
$data['extraHeadContent'] = '<link href="'.site_url("css/rating_style.css").'" rel="stylesheet" type="text/css" media="all">';
$data['extraHeadContent'] .= '[removed][removed]';
$comments = $this->stories_model->get_story_comments($this->uri->segment(3));
$data['comments'] = $comments->row_array();
$this->load->view('story/single', $data);
}
}
stories_model.php (Model)
Code:
class Stories_model extends Model {
function Stories_model()
{
parent::Model();
$this->_prefix = $this->config->item('dbprefix');
}
function get_story_comments($id)
{
$this->db->where('story_id', $id);
return $this->db->get('comments');
}
}
single.php (View)
Code:
<?
$this->load->view("header");
include(".xx..xx...rating_functions.php");
$comment = array(
'name' => 'comment',
'id' => 'comment',
'cols' => 25,
'rows' => 10,
'value' => set_value('comment')
);
?>
<h1><?=$info['title']?></h1>
<br />
<?=$info['story']?>
<br />
<? echo pullRating($info['id'],true,false,true); ?>
<br />
Post Comments:
<br />
<?
if ( ! $this->dx_auth->is_logged_in())
{
echo "Must be logged in to post comments";
}
else
{
?>
<form name="comments" action="<?=site_url('story/postcomment');?>" method="POST">
<input type="hidden" name="story_id" value="<?=$info['id']?>" />
<?
echo form_textarea($comment);
?>
<br />
<?echo form_submit('submit', 'Submit Comment!');?>
</form>
<?
}
?>
<?
$this->load->model('dx_auth/users');
<?=$this->dx_auth->get_user_by_id($comments['user_id']?>
<?=$comments['comment']?>
<?
$this->load->view("footer");
?>