Post by TiM-SE » Fri May 27, 2011 12:25 am

I've searched the web and cannot find a way or variable to determine what page OpenCart is displaying.

My customer wants a different header and footer on the firstpage. So I need some sort of code that does the following in the tpl files:

<?php if ($page == 'firstpage') { ?>
...
<?php } ?>

Any clues?

Newbie

Posts

Joined
Tue May 03, 2011 8:35 am

Post by grgr » Fri May 27, 2011 1:31 am

You can try using:

Code: Select all

<?php
$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo $url;
?>
gets actual page url not a mod_rewrite one.

-
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 TiM-SE » Sat May 28, 2011 2:05 am

Is there no such variable like $this->config->get('route')?

I was hoping for if ($this->config->get('route') == 'common/home')

because I find this solution kind of a mcgyver:
if ($_SERVER['REQUEST_URI'] == '/' || strpos($_SERVER['REQUEST_URI'], 'route=common/home') !== false) {

Newbie

Posts

Joined
Tue May 03, 2011 8:35 am

Post by Qphoria » Sat May 28, 2011 2:12 am

TiM-SE wrote: I was hoping for if ($this->config->get('route') == 'common/home')
So close...

Code: Select all

if (isset($this->request->get['route']) && $this->request->get['route'] == 'common/home') {
/// do some magic
}

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by TiM-SE » Wed Jun 01, 2011 6:12 am

Qphoria, that is the same as:

if (isset($_GET['route']) && $_GET['route'] == 'common/home') {
/// do some magic
}

It would not apply to seo urls or root /.

My previous post seems to do the trick, but in my picky opinion it's one condition too many ;b

if ($_SERVER['REQUEST_URI'] == '/' || strpos($_SERVER['REQUEST_URI'], 'route=common/home') !== false)

Thank you for replying

Newbie

Posts

Joined
Tue May 03, 2011 8:35 am

Post by SXGuy » Wed Jun 01, 2011 3:01 pm

TiM-SE wrote:Qphoria, that is the same as:

if (isset($_GET['route']) && $_GET['route'] == 'common/home') {
/// do some magic
}

It would not apply to seo urls or root /.

My previous post seems to do the trick, but in my picky opinion it's one condition too many ;b

if ($_SERVER['REQUEST_URI'] == '/' || strpos($_SERVER['REQUEST_URI'], 'route=common/home') !== false)

Thank you for replying

adapt it for seo urls then

Code: Select all

if (isset($_GET['route']) && $_GET['route'] == 'common/home' || $_GET['route'] == '/'  || $_GET['route'] == 'My_SEO_URL' ) {
/// do some magic
}
That should work.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am
Who is online

Users browsing this forum: Baidu [Spider] and 13 guests