Post by stefan.hurezan » Fri May 23, 2014 3:41 pm

Hi there,

I am trying to build a template needs a modification in the homepage's header. How can I define that it is the homepage?

I need something like

Code: Select all

if HOMEPAGE { show custom code }
else { standard header code }


Posts

Joined
Fri May 23, 2014 3:37 pm

Post by IP_CAM » Fri May 23, 2014 10:16 pm

You would have to create a special header-template anyway to display
a different Header in your HOME Section. So, you either create
another HOME-Header and link it in the HOME.TPL

Code: Select all

\shop\catalog\view\theme\YOURTEMPLATE\template\common\home.tpl
in this Line of the home.tpl file:

Code: Select all

<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?> 
this would have to be modified:

Code: Select all

<?php echo $header; ?>
into (example):

Code: Select all

<?php echo $header2; ?>
BE AWARE, that the new $VALUE ($header2) would have to be DECLARED in another place to be recognized!
If won't just work by naming the new header-file >header2.tpl< and expect the Software to 'handle' >header2.tpl< as >$header2< , if you know what I'm trying to explain with this...

BUT why then not just modify the

Code: Select all

\shop\catalog\view\theme\YOURTEMPLATE\template\common\home.tpl
by adding, whatever is required from HEADER.TPL Content in order to make the Page
work as it should. The header.tpl is located in the same Sub as the home.tpl File!
I just made a short Test.

This would be my general Header on all Pages:

Image

This would be the modified HOME Page, exept for the BG-Image and
Header CSS-Section-Settings, all 'visible' Header Content has been removed:

Image

This would be the added HOME.TPL Header Source Part,
shown down to just before the <div id="container"> Line.
I did not place it as Source here, because it's different from yours,
but, I guess, it will lead you in the right direction.

Image

This way, you don't need the DEFAULT Header Section to be called at all,
everything required is placed in the HOME.TPL, and the Line:

Code: Select all

<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?> 
just needs to be changed to:

Code: Select all

<?php echo $column_left; ?><?php echo $column_right; ?> 
to remove the DEFAULT Header Call!

Just an Idea, I left some unneeded stuff like the Script Stuff Ref-Lines for my short Test, some (or most) of them could possibly also be removed. It was just my (first error-message-free) FASTDRAW Proof of Concept...

Ernie

I'm rarely active at the OC Forum lately. To reach me, contact: jti@jacob.ch
A Demoversion of my free OpenCart LIGHT v.1.5.6.5 Software Edition
can be seen in real Action here: http://www.jti.li/shop/
---
1'100+ FREE OC Extension-Repositories - from OC v.1.5.x up,
on the world's largest OC-related Github Site: https://github.com/IP-CAM
---
Image


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by stefan.hurezan » Sat May 24, 2014 4:17 am

Hi Ernie,

Thanks for your time and reply. If a simpler solution won't come up I am sure gonna use your solution. The thing is that I am adding a lot of manual coding to the header (links, icons, etc) what I really need to show / hide on homepage / other pages is a div and change a class of an ul. If I use your solution, whenever I change something in the header I would have to change it in two files, which is ok as long as I will be the only one managing the tech / design part. But if someone else is going to mess with the coding I am afraid that the information added manually will not be the same in the two headers after a while.

So, anyone know a solution so I don't need two header files?
Thanks in advance for any contribution to this topic.

Stefan


Posts

Joined
Fri May 23, 2014 3:37 pm

Post by labeshops » Sat May 24, 2014 4:54 am

This code was given a long time ago somewhere in the forums to set a different title for the home page than the other pages. You should be able to use it to display other code as well.

Code: Select all

    <?php if (isset($this->request->get['route']) && $this->request->get['route'] != 'common/home') { ?>
    <title><?php echo $title; ?> text for home page only </title>
    <?php } else { ?>
    <title><?php echo $title; ?> other title info here</title>
    <?php } ?>

Running Opencart v2.2 with multi-stores from http://www.labeshops.com which has links to all my stores.

Image


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by Xyph3r » Sat May 24, 2014 5:49 am

labelshop...You are a little wrong. In your example....the 2 titles should be switched, note if !(not)=(equal)
Switch the titles position or

use this code instead

Code: Select all

  <?php if (!isset($this->request->get['route']) || (isset($this->request->get['route']) && $this->request->get['route'] == 'common/home')) { ?>
 Home Code
  <?php } else { ?>
	Other pages code
  <?php } ?>

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


User avatar
Active Member

Posts

Joined
Sun Feb 10, 2013 1:08 am


Post by stefan.hurezan » Sat May 24, 2014 7:38 pm

Thanks for the help! I managed to do what I needed thanks to it! Have a nice day!


Posts

Joined
Fri May 23, 2014 3:37 pm

Post by idoxlr8 » Wed Jun 04, 2014 4:20 am

Code: Select all

  <?php if (!isset($this->request->get['route']) || (isset($this->request->get['route']) && $this->request->get['route'] == 'common/home')) { ?>
 Home Code
  <?php } else { ?>
	Other pages code
  <?php } ?>
[/quote]
And taking it a bit further...

Code: Select all

<?php
$cust_title = 'your store name';
?>

Code: Select all

<title>
  <?php if (!isset($this->request->get['route']) || (isset($this->request->get['route']) && $this->request->get['route'] == 'common/home')) { 
	echo $title;
   } else { 
   echo $cust_title . ' - ' .  $title;
  } ?>

</title>

Newbie

Posts

Joined
Sat May 31, 2014 5:01 am
Who is online

Users browsing this forum: No registered users and 15 guests