Page 1 of 1

Pagination and number of images showing per picture (option)

Posted: Wed Nov 06, 2013 8:09 pm
by pantrif
Hi and thanks for this great component,

I am trying to give the option to users to select number of images showing per page using dropdown menu.
I modified the function writePagination(). Here my code:

Code: Select all

 function writePagination() {
        // Paggination Support
        $html = "";

	
			$number_per_page = $_REQUEST['npp'];
			$page = $_REQUEST['page'];
	
			 
			if (isset($number_per_page)) {
			$limit = $number_per_page;
			}else{
			$limit = $this->paginImgTotal; // How many items to show per page by default if visitor hasn't used dropdown.
			}
	 
	$html= "
				<form action='' method=POST >
				<input type=hidden name=page value=\"$page\">
				Items Per Page: <select name=\"npp\">
				<option selected>$limit</option>
				<option value=10>10</option>
				<option value=25>25</option>
				<option value=50>50</option>
				</select>
				<input type=submit value=\"Go\">
				</form>
				
		";
        if ($this->params['paginUse']) {
            if ($this->params['paginUse']) {
                if (!empty($limit) && ceil($limit/ $this->params['paginImagesPerGallery']) > 1) {
                    $html.= '<div class="AG_pagin_wrap">';
                    $paginPrev = ($this->paginInitPages[$this->index] - 1);
                    if ($paginPrev >= 1) {
                        $html.= '<a href="" onClick="AG_form_submit_' . $this->articleID . '(' . $this->index . ',' . $paginPrev . ',\'' . $this->imagesFolderName . '\'); return false;" class="AG_pagin_prev">' . JText::_("PREV") . '</a>';
                    }
                    for ($i = 1; $i <= ceil($limit/ $this->params['paginImagesPerGallery']); $i++) {
                        if ($i == $this->paginInitPages[$this->index]) {
                            $html.= '<span class="AG_pagin_current">' . $i . '</span>';
                        } else {
                            $html.= '<a href="" onClick="AG_form_submit_' . $this->articleID . '(' . $this->index . ',' . $i . ',\'' . $this->imagesFolderName . '\',this);return false;" class="AG_pagin_link">' . $i . '</a>';
                        }
                    }
                    $paginNext = ($this->paginInitPages[$this->index] + 1);
                    if ($paginNext <= ceil($limit/ $this->params['paginImagesPerGallery'])) {
                        $html.= '<a href="" onClick="AG_form_submit_' . $this->articleID . '(' . $this->index . ',' . $paginNext . ',\'' . $this->imagesFolderName . '\'); return false;" class="AG_pagin_next">' . JText::_("NEXT") . '</a>';
                    }
                    $html.= '<br style="clear:both"></div>';
                }
            }
        }
        return $html;
    }

But no luck so far!

Thanks in advance!

Re: Pagination and number of images showing per picture (opt

Posted: Mon Nov 11, 2013 2:30 pm
by Vasiljevski
Well that part is OK, but writePagination() is only responsible for displaying page buttons (Prev,1,2,3) under the gallery.
So changing this function is OK, but real modification are needed in loadImageFiles. Here the template actually provides images to the template.

If I find the time I will give you some more info, maybe some code example how to develop what you need.

But I would recommend you to try to make a new template and try to develop all the functionality inside the template.