mod rewrite - DMXzone's PHP Pagination

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Guys, Gals,
I've been working on a project of mine creating a custom little cms. I've managed to go by tutorials and reference material from the php site to get as far as I have. I've got search engine friendly links working with mod rewrite using mysql entry of page alias and my code is like /<?php echo $_row['alias']; ?>.html

Now that was simple to what I have ran into...

DMXzone has a dreamweaver extension called PHP Pagination which creates very nice paging links. But it has a huge class and its function to print links is over my head. I'm new to the list and I know how aggravating it can be to volunteer help and I give everyone many thanks that makes the effort to help others. I'm sure you all are blessed in many ways.

Can a new guy to the list just jump right in and ask for help? - lol

If someone here a guru at mod_rewrite, please help me get through this step because i'm stuck...

My url to my integrated blog is
/blog.html

after click pagination
/blog.html?pageNum_rsBlog=1

my htaccess I have added
<IfModule mod_rewrite.c>
RewriteEngine on 
RewriteRule blog-(.*).html$ /blog.html?pageNum_rsBlog=$1
</IfModule>

my link should end up
/blog-1.html

I hope its ok to post this long function
here is the dmxzone function inside pagination class

function addPagination()
    {
        $pageNo = 1;
        $recPerPage = 1;
        if ($this->recordsetName != "") {
        	$dsName = $this->recordsetName;
        	$offsetName = "pageNum_";
        	$useOffset = 0;
        } else {
        	$dsName = $this->feedGenieName;
        	$offsetName = "offset_";
        	$useOffset = 1;
        	$recPerPage = $this->rowsPerPage;
        }
        
        $this->numPages = ceil($this->rowsTotal / $this->rowsPerPage);
        if ($this->numPages < 2)
        {
            return;
        }
		
        $curPageUrl = substr("/blog.html", strrpos("/blog.html", "/") +1);
		// $curPageUrl = substr($_SERVER['PHP_SELF'], strrpos($_SERVER['PHP_SELF'], "/") +1);
		
        if (isset($_GET[$offsetName.$dsName]))
        {
        		if ($useOffset == 0) {
            	$pageNo = intval($_GET[$offsetName.$dsName]) + 1;
            } else {
            	$pageNo = (intval($_GET[$offsetName.$dsName]) / $this->rowsPerPage) + 1;
            }
        }
        $pageNumParam = $offsetName.$dsName."=";
        $curPageUrl .= "?";
        
        $queryString = "";
        if (!empty($_SERVER['QUERY_STRING'])) 
        {
              $params = explode("&", $_SERVER['QUERY_STRING']);
            $newParams = array();
            foreach ($params as $param) 
            {
                if (stristr($param, $offsetName.$dsName) == false && stristr($param, "totalRows_".$dsName) == false) 
                {
                    array_push($newParams, $param);
                }
            }
            if (count($newParams) != 0) 
            {
                $queryString = "&" . htmlentities(implode("&", $newParams));
              }
        }        
        echo "<div class=\"dmxpagination\">";
        if ($this->showFirstLast)
        {
            if ($pageNo == 1)
            {
                echo "<span class=\"disabled\">".$this->firstLabel."</span>";
            }
            else
            {
                $prev = $pageNo - 1;
                echo "<a href=\"".$curPageUrl.$pageNumParam."0".$queryString."\" class=\"previous\">".$this->firstLabel."</a>";
            }    
        }
        if ($this->showNextPrev)
        {
            if ($pageNo == 1)
            {
                echo "<span class=\"disabled\">".$this->prevLabel."</span>";
            }
            else
            {
                $prev = $pageNo - 1;
                echo "<a href=\"".$curPageUrl.$pageNumParam.($prev-1)*$recPerPage.$queryString."\" class=\"previous\">".$this->prevLabel."</a>";
                
            }    
        }
        if($this->numPages < (($this->outerLinks + $this->adjacentLinks)*2 + 1))
        {
            for ($i = 1; $i < $this->numPages + 1; $i++)
            {
                if ($pageNo == $i)
                {
                    echo "<span class=\"current\">".$i."</span>";
                }
                else
                {
                    echo "<a href=\"".$curPageUrl.$pageNumParam.($i - 1)*$recPerPage.$queryString."\">".$i."</a>";
                }
            }
        }
        else
        {
            if($pageNo < $this->outerLinks + $this->adjacentLinks + 2)
            {
                for ($i = 1; $i < ($this->outerLinks + $this->adjacentLinks*2 + 2); $i++)
                {
                    if ($pageNo == $i)
                    {
                        echo "<span class=\"current\">".$i."</span>";
                    }
                    else
                    {
                        echo "<a href=\"".$curPageUrl.$pageNumParam.($i - 1)*$recPerPage.$queryString."\">".$i."</a>";
                    }
                }
                if ($this->outerLinks > 0)
                {
                    echo $this->pageNumSeparator;
                }    
                for ($i = $this->numPages - $this->outerLinks + 1; $i < $this->numPages + 1; $i++)
                {
                    echo "<a href=\"".$curPageUrl.$pageNumParam.($i - 1)*$recPerPage.$queryString."\">".$i."</a>";
                }
            }
            else 
            {
                if ($pageNo < $this->numPages - $this->outerLinks - $this->adjacentLinks)
                {
                    for ($i = 1; $i < $this->outerLinks + 1; $i++)
                    {
                                echo "<a href=\"".$curPageUrl.$pageNumParam.($i - 1)*$recPerPage.$queryString."\">".$i."</a>";
                    }
                    if ($this->outerLinks > 0)
                    {
                        echo $this->pageNumSeparator;
                    }
                    for ($i = $pageNo - $this->adjacentLinks; $i < $pageNo + $this->adjacentLinks + 1; $i++)
                    {
                        if ($pageNo == $i)
                        {
                            echo "<span class=\"current\">".$i."</span>";
                        }
                        else
                        {
                            echo "<a href=\"".$curPageUrl.$pageNumParam.($i - 1)*$recPerPage.$queryString."\">".$i."</a>";
                        }
                    }
                    if ($this->outerLinks > 0)
                    {
                        echo $this->pageNumSeparator;
                    }
                    for ($i = $this->numPages - $this->outerLinks + 1; $i < $this->numPages + 1; $i++)
                    {
                        echo "<a href=\"".$curPageUrl.$pageNumParam.($i - 1)*$recPerPage.$queryString."\">".$i."</a>";
                    }
                }
                else
                {
                    for ($i = 1; $i < $this->outerLinks + 1; $i++)
                    {
                        echo "<a href=\"".$curPageUrl.$pageNumParam.($i - 1)*$recPerPage.$queryString."\">".$i."</a>";
                    }
                    if ($this->outerLinks > 0)
                    {
                        echo $this->pageNumSeparator;
                    }
                    for($i = $this->numPages - ($this->outerLinks + ($this->adjacentLinks*2)); $i < $this->numPages + 1; $i++)
                    {
                        if ($pageNo == $i)
                        {
                            echo "<span class=\"current\">".$i."</span>";
                        }
                        else
                        {
                            echo "<a href=\"".$curPageUrl.$pageNumParam.($i - 1)*$recPerPage.$queryString."\">".$i."</a>";
                        }
                    }
                }
            }
        }
        if ($this->showNextPrev)
        {
            if ($pageNo == $this->numPages)
            {
                echo "<span class=\"disabled\">".$this->nextLabel."</span>";
            }
            else
            {
                $next = $pageNo + 1;
                echo "<a href=\"".$curPageUrl.$pageNumParam.($next - 1)*$recPerPage.$queryString."\" class=\"next\">".$this->nextLabel."</a>";
            }
        }
        if ($this->showFirstLast)
        {
            if ($pageNo == $this->numPages)
            {
                echo "<span class=\"disabled\">".$this->lastLabel."</span>";
            }
            else
            {
                $next = $pageNo + 1;
                echo "<a href=\"".$curPageUrl.$pageNumParam.($this->numPages - 1)*$recPerPage.$queryString."\" class=\"next\">".$this->lastLabel."</a>";
            }
        }
        echo "</div>";
    }




I have no idea how to fix this function
all advice appreciated
thanks
RD
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux