Welcome Guest, Not a member yet? Register   Sign In
Cannot figure out Pagination + custom design
#1

[eluser]Zero-10[/eluser]
I've been really good at figuring stuff out on my own but the Pagination system is insanely confusing for some reason. I created my own gallery where images can be uploaded and stored via database and the data is displayed fine with the pagination. However, I cannot figure out how to display the results with pagination. My main goal is to get a comment system for articles, and the gallery was used as a way to figure things out and won't be code used in the future. I'm just stating that I managed to use the pagination (table) correctly.

Files:
Controller/entertainment/article
Models/articles/entertainment
Views/entertainment/index | Views/entertainment/comments

Example of URL:
http://www.fakeurl.com/entertainment/4/title-of-article
4 = articleid
title-of-lesson = isn't mandatory but is good for SEO

Article Controller (comments function)
Code:
//removed a bunch of code that is not important for this question like phpbb stuff
            // retrieve article
            $articleid = $this->uri->segment(4, 6);
            $fulltitle = $data['l_title'];
            $this->load->model('articles/get_article','',TRUE);
            $data['article'] = $this->get_article->get_article_by_id_ent($articleid);

            // retrieve pageviews
            $this->load->model('siteviews','',TRUE);
            $data['pageviews'] = $this->siteviews->get_entertainmentviews($articleid);

            // get breadcrumb id
            $id = $this->breadcrumb->get_categoryid_by_article($data['article']);
            $data['crumb'] = $this->_breadcrumb($id);

            $this->db->set('name', $name);
            $this->db->insert('mytable');

            // get last 24 articles
            $data['ladded'] = $this->get_article->get_latest_added_entertainment();

            // get character database
            $this->load->model('character_database','',TRUE);
            $data['ch_characters'] = $this->character_database->get_characters($articleid);

            // friendship system
            $this->load->model('friendship','',TRUE);
            $data['friendpage'] = $this->friendship->get_advertisement('id', $adcategory);
            $data['friendcount'] = $this->friendship->get_viewcountads();
                $data['friendpage2'] = $this->friendship->get_advertisement2('id', $adcategory);
                $data['friendcount2'] = $this->friendship->get_viewcountads2();

            // Retrieve comments
            $this->load->model('articles/comments','',TRUE);

            $this->db->where('database_entertainment', $this->uri->segment(3));
            $data['fullurl'] = $this->get_article->get_article_by_id_ent('full_url', $articleid);

            // load pagination class
            $this->load->library('pagination');
            $config['base_url'] = base_url().'entertainment/articles/information/'.$articleid;
            $config['total_rows'] = $this->db->count_all('database_articles_comments');
            $config['per_page'] = '1';
            $config['full_tag_open'] = '<p>';
            $config['full_tag_close'] = '</p>';

            $this->pagination->initialize($config);
            $data['cm_query'] = $this->comments->get_comments_ent
            $this->load->library('table');
            $this->table->set_heading('cm_articles_id', 'cm_articles_author', 'cm_articles_date', 'cm_articles_body');

            $this->load->view('header', $data, $aid);
            $this->load->view('entertainment/viewarticle', $data, $bodytext);

Models/articles/comments
Code:
&lt;?php

class Comments extends Model {

    function Comments() {
        parent::Model();
    }
            function get_comments_ent($articleid) {
            $this->db->select('*');
            $this->db->from ('database_entertainment_comments AS p');
            $this->db->join('phpbb_users AS b', 'p.cme_articles_author = b.user_id', 'left');
            $this->db->where('p.cme_articles_article =', $articleid);
            $this->db->order_by('p.cme_articles_date', 'desc');
            $this->db->limit($per_page);

            return $this->db->get();
    }
        function add_comment($data)
        {
            $this->db->insert('database_entertainment_comments', $data);
            return;
        }
}

?&gt;

View/entertainment/comments
-- No point in adding header and index files --
Code:
&lt;? if ($cm_query->num_rows() >0): ?&gt;
    &lt;? foreach($cm_query->result() as $row): ?&gt;
<div>//comment div and things like &lt;?=$row->username?&gt; says: has been removed for simplicity</div>
    &lt;?php endforeach; ?&gt;
&lt;? endif; ?&gt;
//more code deleted for simplicity including the num_rows else case.
&lt;?php echo $this->pagination->create_links(); ?&gt;

I have read like 15 different tutorials (they are all the same copypata), watched the nettuts video, and even went on youtube and other video sites for other screencasts but they don't go into how to customize it. Eventually I would love to have a "load more comments" with jquery but I'll be more than content with getting this done.

Thank you for your time!


Messages In This Thread
Cannot figure out Pagination + custom design - by El Forum - 05-07-2011, 02:54 PM
Cannot figure out Pagination + custom design - by El Forum - 05-09-2011, 08:45 PM
Cannot figure out Pagination + custom design - by El Forum - 05-10-2011, 08:27 AM
Cannot figure out Pagination + custom design - by El Forum - 05-10-2011, 01:07 PM
Cannot figure out Pagination + custom design - by El Forum - 05-14-2011, 06:24 PM



Theme © iAndrew 2016 - Forum software by © MyBB