Post by pkn1001 » Sun Feb 02, 2014 6:53 pm

Dear Team,

UI enhancement - When user add products and go to Checkout page, at that stage I want hide a >>Topside menu and Header from the user
OR
I need to show a custom template only for Checkout page

How it is possible..

Kind regards
Padmaraj

Newbie

Posts

Joined
Tue Nov 26, 2013 11:41 pm

Post by Xyph3r » Sun Feb 02, 2014 11:06 pm

Hello.
Use this inside header.tpl to hide certain items on checkout page.

Code: Select all

<?php if (isset($this->request->get['route']) && $this->request->get['route'] == 'checkout/checkout') { ?>
The code that will appear on checkout page
<?php } else { ?>
hidden code on checkout page and visible on other pages.
<?php } ?>

ImageImageImage
Opencart Templates, Modules, Themes & Custom Development | ShopThemer


User avatar
Active Member

Posts

Joined
Sun Feb 10, 2013 1:08 am


Post by pkn1001 » Mon Feb 03, 2014 5:21 am

Dear Xyph3r
,
Its not working ..

Newbie

Posts

Joined
Tue Nov 26, 2013 11:41 pm

Post by Xyph3r » Mon Feb 03, 2014 4:51 pm

It's working.

And if you want to hide the menu on checkout and not display anything

Code: Select all

<?php if (!isset($this->request->get['route']) || (isset($this->request->get['route']) && $this->request->get['route'] != 'checkout/checkout')) { ?>
hidden code on checkout page and visible on other pages.
<?php } ?>
for the menu on default template...it will look like this

Code: Select all

<?php if (!isset($this->request->get['route']) || (isset($this->request->get['route']) && $this->request->get['route'] != 'checkout/checkout')) { ?>
<?php if ($categories) { ?>
<div id="menu">
  <ul>
    <?php foreach ($categories as $category) { ?>
    <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
      <?php if ($category['children']) { ?>
      <div>
        <?php for ($i = 0; $i < count($category['children']);) { ?>
        <ul>
          <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
          <?php for (; $i < $j; $i++) { ?>
          <?php if (isset($category['children'][$i])) { ?>
          <li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
          <?php } ?>
          <?php } ?>
        </ul>
        <?php } ?>
      </div>
      <?php } ?>
    </li>
    <?php } ?>
  </ul>
</div>
<?php } ?>
<?php } ?>
the whole header...in default 1.5.6.1..this

Code: Select all

<?php if (!isset($this->request->get['route']) || (isset($this->request->get['route']) && $this->request->get['route'] != 'checkout/checkout')) { ?>
<div id="header">
  <?php if ($logo) { ?>
  <div id="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
  <?php } ?>
  <?php echo $language; ?>
  <?php echo $currency; ?>
  <?php echo $cart; ?>
  <div id="search">
    <div class="button-search"></div>
    <input type="text" name="search" placeholder="<?php echo $text_search; ?>" value="<?php echo $search; ?>" />
  </div>
  <div id="welcome">
    <?php if (!$logged) { ?>
    <?php echo $text_welcome; ?>
    <?php } else { ?>
    <?php echo $text_logged; ?>
    <?php } ?>
  </div>
  <div class="links"><a href="<?php echo $home; ?>"><?php echo $text_home; ?></a><a href="<?php echo $wishlist; ?>" id="wishlist-total"><?php echo $text_wishlist; ?></a><a href="<?php echo $account; ?>"><?php echo $text_account; ?></a><a href="<?php echo $shopping_cart; ?>"><?php echo $text_shopping_cart; ?></a><a href="<?php echo $checkout; ?>"><?php echo $text_checkout; ?></a></div>
</div>
<?php if ($categories) { ?>
<div id="menu">
  <ul>
    <?php foreach ($categories as $category) { ?>
    <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
      <?php if ($category['children']) { ?>
      <div>
        <?php for ($i = 0; $i < count($category['children']);) { ?>
        <ul>
          <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
          <?php for (; $i < $j; $i++) { ?>
          <?php if (isset($category['children'][$i])) { ?>
          <li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
          <?php } ?>
          <?php } ?>
        </ul>
        <?php } ?>
      </div>
      <?php } ?>
    </li>
    <?php } ?>
  </ul>
</div>
<?php } ?>
<?php } ?>

If you want to display something in header place...use the code provided by me in the other post

ImageImageImage
Opencart Templates, Modules, Themes & Custom Development | ShopThemer


User avatar
Active Member

Posts

Joined
Sun Feb 10, 2013 1:08 am


Post by Pumbaa » Sun Feb 23, 2014 2:08 am

Hello Xyph3r,

I really appreciate your help, your code works greatly, but there is one issue, when I´m on checkout or cart page (with checkout template) and I click link that redirects me to another page - homepage, product or category - which is not on a checkout template, orginal header will not return and header for checkout remains displayed instead.

My webpage is http://www.alsatech.sk, but I think this is not caused by my code.

I think there should be a simple solution for this, but I can´t figure out by myself.

Do you have any solution for this ?

Thank you.

Všetko pre Skylink a freeSAT- OC 1.5.4.1


Newbie

Posts

Joined
Fri Oct 26, 2012 4:56 pm

Post by Pumbaa » Sun Feb 23, 2014 5:29 am

I think I´ve figured it out, I ´ve changed controller file header.php instead of changing header template.

Original code:

Code: Select all

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/common/header.tpl';
		} else {
			$this->template = 'default/template/common/header.tpl';
		}

New code:

Code: Select all

if (!isset($this->request->get['route'])) {
        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
            $this->template = $this->config->get('config_template') . '/template/common/header.tpl';
        } else {
            $this->template = 'default/template/common/header.tpl';
        }
    } elseif (($this->request->get['route'] == 'checkout/cart') || ($this->request->get['route'] == 'checkout/checkout')) {
        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header_checkout.tpl')) {
            $this->template = $this->config->get('config_template') . '/template/common/header_checkout.tpl';
        } else {
            $this->template = 'default/template/common/header_checkout.tpl';
        }
    } else  {
        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
            $this->template = $this->config->get('config_template') . '/template/common/header.tpl';
        } else {
            $this->template = 'default/template/common/header.tpl';
        }    
    }

I´ve also created new template file for header - header_checkout.tpl which is triggered on checkout/cart and checkout/checkout templates. Don´t forget to include head tags and scripts from original header.tpl, and also container div and notification div from bottom of original header.tpl file.

Všetko pre Skylink a freeSAT- OC 1.5.4.1


Newbie

Posts

Joined
Fri Oct 26, 2012 4:56 pm
Who is online

Users browsing this forum: No registered users and 43 guests