Post by blackwebs » Wed Mar 28, 2012 5:44 pm

Hi!

Does anyone know how I can have conditional content on the index page, I want to have specific FB Opengraph data on the home page but not on the product pages etc... so I'm looking for this type of script:

IF Page = Home then...

Else

End


Many thanks!
Tom

Newbie

Posts

Joined
Fri Mar 23, 2012 8:53 pm

Post by JAY6390 » Wed Mar 28, 2012 7:08 pm

Code: Select all

<?php if(!empty($this->request->get['route']) && $this->request->get['route'] == 'common/home') : ?>

<?php else: ?>

<?php endif; ?>

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by ThePath » Fri Jul 27, 2012 11:00 pm

Yeh Ive used:

Code: Select all

if (isset($this->request->get['route']) && $this->request->get['route'] == 'common/home') {
But it only works if you are on: http://mysite.com/index.php?route=common/home

It doesnt if you are on: http://mysite.com/

Anyone know how to fix this?

Image

OpenCart Theme Options - See All My Extensions - OpenCart Themes and Mods


User avatar
Active Member

Posts

Joined
Fri Jun 26, 2009 11:53 pm
Location - Scotland

Post by ThePath » Fri Jul 27, 2012 11:32 pm

Found solution:

<?php if (!isset($this->request->get['route']) || (isset($this->request->get['route']) && $this->request->get['route'] == 'common/home')) { ?>

Image

OpenCart Theme Options - See All My Extensions - OpenCart Themes and Mods


User avatar
Active Member

Posts

Joined
Fri Jun 26, 2009 11:53 pm
Location - Scotland

Post by beattie » Sun Sep 02, 2012 8:35 am

Thank you for your solution. The end curly tag } in your last post brought up an error message for me (OC v.1.5.2.1):

This worked for me:

Code: Select all

<?php if (!isset($this->request->get['route']) || (isset($this->request->get['route']) && $this->request->get['route'] == 'common/home')) : ?>
   
This is the text if it is the home page
    <?php else: ?>

This is the text if it is not the home page
    <?php endif; ?>

New member

Posts

Joined
Tue May 22, 2012 11:33 am
Location - Australia
Who is online

Users browsing this forum: No registered users and 22 guests