Part of the EllisLab Network
   
 
Pagination create_links() will not appear
Posted: 28 June 2009 06:45 AM   [ Ignore ]  
Summer Student
Total Posts:  29
Joined  05-25-2009

Hey, I’m have been creating a comments system for my site today and I cannot get the pagination links to appear. I have managed to get the links to appear in the past but not now. The only thing different is that I am coding this as a library not a controller.

This is my library function:

// Library = Ludatha
function getComments($type, $id, $url, $colspan = 1, $offset = 0, $perPage = 10){
        $CI
=& get_instance();
        
$offset2 = $offset + $perPage;
        
$query = $CI->db->query("SELECT * FROM comments WHERE forId = '$id' AND type = '$type' LIMIT $offset, $offset2");
        
$comments = '';
        if (
$query->num_rows() > 0)
        
{
            $config[
'base_url'] = $this->baselink . $url;
            
$config['total_rows'] = $query->num_rows();
            
$config['per_page'] = $perPage;
            
$config['uri_segment'] = 4;
            foreach (
$query->result() as $row){
                $comments
.= '<tr><td colspan="'.$colspan.'">comments</td></tr>';
            
}
            $CI
->pagination->initialize($config);
            
$comments .= '<tr><th colspan="'.$colspan.'">'.$CI->pagination->create_links().'</th></tr>';
        
}else{
            $comments
.= '<tr><td colspan="'.$colspan.'">There are no comments yet.</td></tr>';
        
}
        
return $comments;
    
}
$this->ludatha->getComments(1, 1, $this->ludatha->baselink . "profile/view/" . $username, 3, $comOffset)


The data appears, and when I add /10 to the end of the URL the next 10 results are displayed. The only thing wrong is the fact that the create_links() function will not show anything at all.

My errors are generally ones that I cannot see but are pretty simple, so I am sorry if this is a simple thing to fix :)

Can anyone shed any light?

Thanks

- Adam

Profile
 
 
Posted: 29 June 2009 06:15 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  29
Joined  05-25-2009

Can anyone shed any light on this?

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120401 Total Logged-in Users: 24
Total Topics: 126509 Total Anonymous Users: 4
Total Replies: 665245 Total Guests: 325
Total Posts: 791754    
Members ( View Memberlist )