Pagination Help..

Forum
Last Post
Threads / Messages

FounderSim

Member
Member
Joined
Sep 23, 2014
Messages
65
Points
0
Mysidian Dollar
4,975
I am having trouble getting the pagination class to work in class_profile.php

I have the following code:

Code:
		$total = $mysidia->db->select(DUMMY_TEXT")->rowCount();
		
		if($total > 0)
		{
			
			
			$pagination = new Pagination($total, 10, "profile/view/{$mysidia->input->get("user")}");
			$pagination->setPage($mysidia->input->get("page"));	
///query loop result
$stmt = $mysidia->db->select("dummy_table", array("fieldID"), "DUMMY_QUERY ORDER BY fieldID LIMIT {$pagination->getLimit()},{$pagination->getRowsperPage()}");
$document->addLangvar($pagination->showPage());
                 }

It shows the text:
pagination.png

It navigates the to the page; url = www.dummyurl.com/profile/view/siminator/page-5

I can't fetch page #5 for some reason =0... Any ideas.
 
I don't know how to use the pagination class, sorry. =/ I'd love to have it work on the profiles, too. I ended up using an iframe and I hate my solution.
 
It seems like the problem lies in the class_input.php file

In class_userprofile.php I got this line

Code:
$mysidia->input->get("page")

In the class_input.php file I got this:

Code:
    /**
     * The get method, returns a user input var stored in Input::$get property.
	 * @param String  $key
     * @access public
     * @return Object
     */
    public function get($key = ""){
		echo $key;
        if(empty($key) and $this->get instanceof HashMap)
		{
			return $this->get;
		}			
		else
		{
		echo ' =  ' . $this->get->get(new String($key)) . "<BR>";
		return $this->get->get(new String($key));
		}
    }


Output:
frontcontroller = index
appcontroller = profile
user = siminator
frontcontroller = index
appcontroller = profile
appcontroller = profile
appcontroller = profile
frontcontroller = index
appcontroller = profile
user = siminator
user = siminator
user = siminator
user = siminator
user = siminator
user = siminator
user = siminator
user = siminator
user = siminator
page =
user = siminator
frontcontroller = index
appcontroller = profile

@Hall of Famer

Page is always blank... I must be missing something.
 
I guess I am going to try a little work-a-round. Going to add a line or two to mod-rewrite.

Will keep ya'll posted especially you @kyttias
 
I came up with a workable solution without I-frames or mod rewritting. Not much code needed. Here it is for profile pages:

The first three lines are just incase a user has a name with "page-" in it. It would totally screw up the script.
Code:
		$strz = $mysidia->path->getTempRoot() . "profile/view/{$mysidia->input->get("user")}/";
		$lenn = strlen($strz);

		if(strpos($_SERVER['REQUEST_URI'] ,"page-") == $lenn)
		{

			$newStr = str_replace($strz . "page-", "", $_SERVER['REQUEST_URI']);
			$pageNum = str_replace("/", "", $newStr); 
die($pageNum); //shows page # 

		}
 
Hmm... so what are all the steps we need to go through?

It'd be awesome if you could post your findings as an actual mod! :usedusedused:
 
Here's an explanation:

In myadopts.php the pagination class uses this to show "pagination"

Code:
$total = $mysidia->db->select("owned_adoptables", array("aid"), "aid {$commandIn} AND owner = '{$mysidia->user->username}'")->rowCount();
			
			
			$pagination = new Pagination($total, 10, "myadopts");
			$pagination->setPage($mysidia->input->get("page"));	//Sets CURRENT PAGE

The error lyes in $mysidia->input->get("page") when used in the userprofile pages, it doesn't work at all. It is always blank.

class input get method used in pagination.

I edited styling. Debugging shown in Post #4.
Code:
/**
     * The get method, returns a user input var stored in Input::$get property.
	 * @param String  $key
     * @access public
     * @return Object
     */
    public function get($key = ""){
        if(empty($key) and $this->get instanceof HashMap)
		{
			return $this->get;
		}			
		else
		{
		return $this->get->get(new String($key));
		}
    }

So using the pagination class wasn't a complete waist. The pagination class is fine, its fetching the page # from $_GET[] that was the issue.

In the class_userprofile.php, I duplicated what the FULL URL should look like without page #'s.

Code:
$strz = $mysidia->path->getTempRoot() . "profile/view/{$mysidia->input->get("user")}/"; //duplicated URL, no page #

stored length of duplicated URL
Code:
$lenn = strlen($strz);

I then checked if page- is next available characters in URL.
Code:
if(strpos($_SERVER['REQUEST_URI'] ,"page-") == $lenn)

If page- is the next available characters in URL. I strip out everything but the # by replacing my duplicated URL and "page-" in the REAL URL with nothing.

Code:
$newStr = str_replace($strz . "page-", "", $_SERVER['REQUEST_URI']);

Since the pagination class is perfectly OK and it was the class INPUT method get, I just plugged my stripped page # from URL into the pagination class to tell the class what page # I was on.

Code:
$pagination->setPage($newStr);


In USE:
Code:
		$newStr = "";
		$strz = $mysidia->path->getTempRoot() . "profile/view/{$mysidia->input->get("user")}/";
		$lenn = strlen($strz);

		if(strpos($_SERVER['REQUEST_URI'] ,"page-") == $lenn)
		{
			$newStr = str_replace($strz . "page-", "", $_SERVER['REQUEST_URI']);
		}

                       //use pagination class. set URL. SET PAGE its on. Show pagination navigation.
			$pagination = new Pagination($total, 10, "profile/view/{$mysidia->input->get("user")}");

			$pagination->setPage($newStr);	

			$document->addLangvar($pagination->showPage());
 
Where should this code go inside what file? I'm still not clear on how to use this information to paginate the user pets on the profile. :desudesudesu:
 
Where should this code go inside what file? I'm still not clear on how to use this information to paginate the user pets on the profile. :desudesudesu:

It will go inside class_userprofile.php somewhere. I modified the file heavily so not sure what the original file looks like anymore. =}
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,280
Messages
33,130
Members
1,603
Latest member
Monako
BETA

Latest Threads

Latest Posts

Top