Post by ianhaney50 » Sat Jun 15, 2024 4:53 pm

I am trying to modify the error/not_found page but found out the empty shopping cart and some other pages use that template as well so the same code ends up on the The page you requested cannot be found! and also empty shopping cart content.

I am trying to make a custom 404 page and found a topic for opencart 1.5 that I could use php if and else statements but it don't seem to work, it still displays the same content on both page you requested cannot be found! and also empty shopping cart

Below is what I have in error/not_found.tpl file

Code: Select all

<?php if (!isset($this->request->get['route']) || (isset($this->request->get['route']) && $this->request->get['route'] == 'error/not_found')) { ?>
      <div id="content" class="col-sm-12">
          <h1><?php echo $heading_title; ?></h1>
          <p>NOT FOUND PAGE NEW</p>
          <?php } else { ?>
    <div id="content" class="<?php echo $class; ?>">
        <?php echo $content_top; ?>
      <h1><?php echo $heading_title; ?></h1>
      <p><?php echo $text_error; ?></p>
        <?php echo $content_bottom; ?>
      </div>
    <?php echo $column_right; ?>
      <?php } ?>
Should I need to do something in the controller file or will it just not work because they use the same template file.

I am using 2.3.0.2

New member

Posts

Joined
Fri Apr 29, 2016 4:21 am

Post by grgr » Sun Jun 16, 2024 8:47 am

Essentially what you have done there but do it in the controller file - wrap the last line that loads the template file in the if statment and then create/add a new template (.tpl) file.

-
Image Image Image Image
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS


User avatar
Active Member

Posts

Joined
Mon Mar 28, 2011 4:08 pm
Location - UK

Post by ianhaney50 » Sun Jun 16, 2024 3:49 pm

grgr wrote:
Sun Jun 16, 2024 8:47 am
Essentially what you have done there but do it in the controller file - wrap the last line that loads the template file in the if statment and then create/add a new template (.tpl) file.
I managed to find a different way of doing it. I did the following, hopefully it helps if others are looking to do the same thing

In catalog/controller/checkout/cart.php I did the following

In

Code: Select all

public function index() {
code I replaced the line

Code: Select all

$this->response->setOutput($this->load->view('error/not_found', $data));
with the code

Code: Select all

$this->response->setOutput($this->load->view('error/empty_basket', $data));
I then created a new tpl file in catalog/view/theme/default/error/ folder called empty_basket.tpl for the empty shopping cart page and then in the catalog/view/theme/default/error/not_found.tpl I did the custom 404 code I wanted like below

Code: Select all

<div id="content404" class="<?php echo $class; ?>">
            <?php echo $content_top; ?>
            <div class="fourzerofourbg">
                <h1 class="fourzerofourheading">404</h1>
                <p class="fourzerofourtext">
                    Oops! Something is wrong.
                    <br><br>
                    The product or page your looking for has moved, got deleted, is hiding or in quarantine or never existed
                    <br><br>
                    <a class="fourzerofourbuttondesktop hidden-xs hidden-sm" href="/shop/"><i class="icon-home"></i> Let's go home and try from there</a>
                    <a class="fourzerofourbuttonmobile hidden-md hidden-lg" href="/shop/"><i class="icon-home"></i> Let's go home and try from there</a>
                    <br><br>
                    or try the search bar above or search from the categories below.
                </p>
            </div>
        </div>
It seems to be working that way as the page you requested is not found now has that above code and the empty shopping cart page (empty_basket.tpl) has the your cart is empty content so are two seperate pages now

New member

Posts

Joined
Fri Apr 29, 2016 4:21 am
Who is online

Users browsing this forum: Bing [Bot] and 38 guests