View Single Post
  #8  
Old 03-05-2016, 02:10 AM
FounderSim FounderSim is offline
Member
 
Join Date: Sep 2014
Posts: 65
Gender: Male
Credits: 7,897
FounderSim is on a distinguished road
Default

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());
__________________
Reply With Quote