Hello,
I want to change the "Result Pages: 1 of 3" with some links PREVIOUS/NEXT to navigate through the products pages or something like this: "Pages: [1] 2 3 4 ... 8".
Is it possible? (Actually, I would like to have both).
No one sees and click on the "Result Pages: 1 of 3" to change to next page.
I want to change the "Result Pages: 1 of 3" with some links PREVIOUS/NEXT to navigate through the products pages or something like this: "Pages: [1] 2 3 4 ... 8".
Is it possible? (Actually, I would like to have both).
No one sees and click on the "Result Pages: 1 of 3" to change to next page.
You have to change two files and create a new file.
Step1:
Create a new file in your {template}/content directory.
Copy and paste the following code to the new file and name it with _pagination.tpl
Step2:
Editing catalog/template/default/content/category.tpl
Step 2-1:
Rename the variable name ($pages) in the loop, so that we can use the original $pages later in our _pagination.tpl
Step 2-2:
Place the following code in which place you want to display.
Step 3:
Edit catalog/controller/category.php
Step 3-1:
Find $page_data[] and add the url for page link.
Step 3-2:
Find function page()
Good Luck!
Step1:
Create a new file in your {template}/content directory.
Copy and paste the following code to the new file and name it with _pagination.tpl
Code: Select all
<div class="pagination">
<?php foreach ($pages as $p): ?>
<?php if ($p['value'] == $page): ?>
<a href="<?php echo $p['href']?>" class="active"><?php echo $p['value']?></a>
<?php else: ?>
<a href="<?php echo $p['href']?>"><?php echo $p['value']?></a>
<?php endif; ?>
<?php endforeach; ?>
</div>
Editing catalog/template/default/content/category.tpl
Step 2-1:
Rename the variable name ($pages) in the loop, so that we can use the original $pages later in our _pagination.tpl
Code: Select all
// FIND
<?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 } ?>
// REPLACE WITH
<?php foreach ($pages as $p) { ?>
<?php if ($p['value'] == $page) { ?>
<option value="<?php echo $p['value']; ?>" SELECTED><?php echo $p['text']; ?></option>
<?php } else { ?>
<option value="<?php echo $p['value']; ?>"><?php echo $p['text']; ?></option>
<?php } ?>
<?php } ?>
Place the following code in which place you want to display.
Code: Select all
<?php include_once '_pagination.tpl'; ?>
Step 3:
Edit catalog/controller/category.php
Step 3-1:
Find $page_data[] and add the url for page link.
Code: Select all
<?php
$page_data[] = array(
'text' => $language->get('text_pages', $i, $database->getPages()),
'value' => $i,
// Add url for page link
'href' => $url->href('category', 'page', array(
'path' => $request->get('path'),
'page' => $i
))
// Add url for page link -- END
);
?>
Step 3-2:
Find function page()
Code: Select all
<?php
function page() {
$request =& $this->locator->get('request');
$response =& $this->locator->get('response');
$session =& $this->locator->get('session');
$url =& $this->locator->get('url');
/* Comment out these code
if ($request->has('page', 'post')) {
$session->set(($request->has('path') ? 'category.' . $request->get('path') . '.page' : 'category.page'), $request->get('page', 'post'));
}
*/
// Add $_GET support
$page = $request->get('page');
if (!$page) {
$page = $request->get('page', 'post');
}
if ($page) {
$session->set(($request->has('path') ? 'category.' . $request->get('path') . '.page' : 'category.page'), $page);
}
// Add $_GET support -- END
$response->redirect($url->ssl('category', FALSE, array('path' => $request->get('path'))));
}
?>
Good Luck!

Last edited by beata on Sun Nov 11, 2007 10:47 pm, edited 1 time in total.
Thanks Beata,
That's working though I didn't know to follow your steps.
Here is what I have done:
First I have created the _pagination.tpl page:
And in category.tpl:
No need to do more. It works well.
By the way, if I try to change the code in category.php I get an error so I didn't try.
Thanks again.
That's working though I didn't know to follow your steps.
Here is what I have done:
First I have created the _pagination.tpl page:
Code: Select all
<div class="paginate">
Pages:
<?php foreach ($pages as $p): ?>
<?php if ($p['value'] == $page): ?>
<a class="active" href="<?php echo $p['href']?>">[<?php echo $p['value']?>]</a>
<?php else: ?>
<a href="<?php echo $p['href']?>"><u><?php echo $p['value']?></u></a>
<?php endif; ?>
<?php endforeach; ?>
</div>
Code: Select all
<div class="results">
<div class="left"><?php echo $text_results; ?></div>
<div class="right"><?php include '_paginate.tpl'; ?></div>
</div>
By the way, if I try to change the code in category.php I get an error so I didn't try.
Thanks again.
Last edited by jeeremie on Mon Nov 12, 2007 1:33 am, edited 1 time in total.
Sorry, my friend told me I should use 'pagination' instead of 'paginate'
So I have changed 'paginate' into 'pagination'.
in _pagination.tpl
in category.tpl
And... I didn't try this code in any other version of opencart 0.7.7
So I have changed 'paginate' into 'pagination'.
in _pagination.tpl
Code: Select all
<div class="paginate"> // let it be 'pagination'
Code: Select all
<?php include '_paginate.tpl'; ?> // same as above, change the include path into '_pagination.tpl'
Can you provide the error message?jeeremie wrote: By the way, if I try to change the code in category.php I get an error so I didn't try.
And... I didn't try this code in any other version of opencart 0.7.7
Last edited by beata on Mon Nov 12, 2007 2:42 am, edited 1 time in total.
I get this error:
Fatal error: Call to undefined method language::get() in /home/webkreat/public_html/hailstormdesign/catalog/plugin/category.php on line 43
It occurs when I add this code in category.php:
I think I have version 0.9 but i am not sure. How do I know my version?
Fatal error: Call to undefined method language::get() in /home/webkreat/public_html/hailstormdesign/catalog/plugin/category.php on line 43
It occurs when I add this code in category.php:
Code: Select all
<?php
$page_data[] = array(
'text' => $language->get('text_pages', $i, $database->getPages()),
'value' => $i,
// Add url for page link
'href' => $url->href('category', 'page', array(
'path' => $request->get('path'),
'page' => $i
))
// Add url for page link -- END
);
?>
Wow.. you got a future version of opencart!! (The current release is 0.7.7)jeeremie wrote: I get this error:
Fatal error: Call to undefined method language::get() in /home/webkreat/public_html/hailstormdesign/catalog/plugin/category.php on line 43
I think I have version 0.9 but i am not sure. How do I know my version?
Actually, I can't get any version information from source code either.

Who is online
Users browsing this forum: No registered users and 4 guests