Post by jarek » Wed May 21, 2008 5:41 am

Hi all!

I've just implemented next/previous buttons for changing pages in category.

In category.php you have to do:

Code: Select all

$view->set('action', $url->href('category', 'page', array('path' => $request->get('path'))));
// Prev/next button by JT
$page = $request->has('path') ? $session->get('category.' . $request->get('path') . '.page') : $session->get('category.page');
$view->set('page', $page );

// End prev/next button by JT

$page_data = array();



for ($i = 1; $i <= $database->getPages(); $i++) {

        			$page_data[] = array(

          				'text'  => $language->get('text_pages', $i, $database->getPages()),

          				'value' => $i

        			);

      			}
// Prev/next button by JT
if( $i>$page+1 )
	$view->set('page_next', max(2,$page+1) );
if( $page > 1 )
	$view->set('page_previous', $page-1 );


// End prev/next button by JT
$view->set('pages', $page_data);

And in category.tpl:

Code: Select all

    <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" name="pageselector">
	  <?php if(isset($page_previous)) { ?>
	  <input class="pager" type="image" src="catalog/template/default/image/button_previous.png" onclick="getElementById('pageselect').value='<?php echo $page_previous ?>';">
	  <?php } ?>

      <select id="pageselect" class="inputselect" name="page" onchange="this.form.submit();">

        <?php foreach ($pages as $pages) { ?>

        <?php if ($pages['value'] == $page) { ?>

        <option value="<?php echo $pages['value']; ?>" SELECTED><?php echo $pages['text']; ?></option>

        <?php } else { ?>

        <option value="<?php echo $pages['value']; ?>"><?php echo $pages['text']; ?></option>

        <?php } ?>

        <?php } ?>

      </select>
	  <?php if(isset($page_next)) { ?>
	  <input class="pager" type="image" src="catalog/template/default/image/button_next.png" onclick="getElementById('pageselect').value='<?php echo $page_next ?>';">
	  <?php } ?>

    </form>

And of course you have to add some button images (button_next.png and button_previous.png) and create style in default.css.
I.e.:

Code: Select all

input.pager {
	width: 16px;
	height: 16px;
	vertical-align: bottom;
	padding-left: 2px;
	padding-bottom: 2px;
	background: none;
	border: none;
	top:2px;
}
Working example: http://lumisklep.pl/index.php?controlle ... ry&path=22

I'd like to add this buttons to all places where we have page select.
Good luck
JT

Newbie

Posts

Joined
Mon May 05, 2008 1:41 pm

Post by mcphearson » Tue Jun 10, 2008 1:33 am

which category.php is it?? whats the path?

Do i add this code or do i replace my existing code completley with it?

If i add where do i add it?

User avatar
Newbie

Posts

Joined
Mon Jun 09, 2008 2:05 am


Post by sakathecheetah » Fri Jul 04, 2008 1:01 pm

which category.php is it?? whats the path?
That should be the controller for category (./catalog/controller/category.php)... I think the only other category.php is the language file, which would not make sense at all.
Do i add this code or do i replace my existing code completley with it?

If i add where do i add it?
Well, first of all, if you don't feel comfortable, you probably shouldn't start pasting code... so at least make backups first.

The category controller (category.php) is a big piece of code, but it's pretty straightforward if you look for that area. Around line 95, you'll see where that code block begins. Add the part that jarek commented after the for loop as shown, not the whole code block.

The code given for category.tpl begins around line 20 in the default template. Replace the entire ... with the one given here.

...and finally (if not obviously) the CSS works just fine added to the bottom of default.css in the default template, or whichever css files you've linked to your template.

New member

Posts

Joined
Wed Jul 02, 2008 8:50 am

Post by johny2k » Thu Aug 07, 2008 4:28 pm

Thanks For Your Sharing!!!!! You Are My God!!!!  ;D ;D ;D

New member

Posts

Joined
Tue Mar 04, 2008 4:35 pm
Who is online

Users browsing this forum: No registered users and 1 guest