Post by scott23 » Sun Feb 06, 2011 6:22 am

Hello All,

Has anyone found an effective way to edit a module so that it can be hidden on specified pages?

Thanks,

Scott

User avatar
New member

Posts

Joined
Sun Feb 06, 2011 6:08 am

Post by justinv » Sun Feb 06, 2011 11:32 am

You could do it based on a check in the tpl file for that module to make sure it is not the page you want to hide the module on.

Code: Select all

<?php if ($this->request->get("route") != common/home) { ?>.....module code......<?php } ?> 

Documentation: OpenCart User Guide
Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN
Image


Active Member

Posts

Joined
Tue Oct 12, 2010 1:24 pm

Post by scott23 » Sun Feb 06, 2011 2:08 pm

Justinv,

Thanks for the suggestion. I tried this on one of the modules but it causes the website to have an error 500 until I remove the script. Any ideas?

Scott

**EDIT**

Believe I found the code that works.

Code: Select all

<?php if($this->request->get['route'] == 'product/product' || $this->request->get['route'] == 'account/login'){ ?>.....module.......<?php } ?>

User avatar
New member

Posts

Joined
Sun Feb 06, 2011 6:08 am

Post by justinv » Sun Feb 06, 2011 5:16 pm

Not sure about the code you just posted, but this should work...

Put this in your catalog/controller/module/module_name.php:

Code: Select all

$this->data['route'] = $this->request->get("route");
Then do this in your tpl file:

Code: Select all

    <?php if($route == 'product/product' || $route == 'account/login'){ ?>.....module.......<?php } ?>
That's how I'd do it. If it's already working, I wouldn't change it though :)

Documentation: OpenCart User Guide
Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN
Image


Active Member

Posts

Joined
Tue Oct 12, 2010 1:24 pm

Post by scott23 » Mon Feb 07, 2011 12:35 am

The code that I was using works correctly but gives an undefined index error when the Display Error is turned on.

I tried your code but the

Code: Select all

$this->data['route'] = $this->request->get("route");
gives me a Fatal error: Call to undefined method Request::get() when I try to bring up the page. If I remove that code from the module.php the page begins working again. Any ideas?

Thanks,

Scott

User avatar
New member

Posts

Joined
Sun Feb 06, 2011 6:08 am

Post by justinv » Mon Feb 07, 2011 4:24 am

Hmm.. you're right. Don't know how I messed that up straight after I checked!

It should be:

Code: Select all

$this->data['route'] = $this->request->get['route'];
Alternatively, you could fix yours by checking that the index exists before trying to compare it, ie:

Code: Select all

if (isset($this->request->get['route']) && ($this->request->get['route'] == 'product/product' || $this->request->get['route'] == 'account/login')) { ?>

Documentation: OpenCart User Guide
Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN
Image


Active Member

Posts

Joined
Tue Oct 12, 2010 1:24 pm

Post by scott23 » Mon Feb 07, 2011 5:38 am

I still received an error when using

Code: Select all

$this->data['route'] = $this->request->get['route'];
but using this code

Code: Select all

if (isset($this->request->get['route']) && ($this->request->get['route'] == 'product/product' || $this->request->get['route'] == 'account/login')) { ?>
works perfectly without any errors at all.

Thank you for all of your help, Justinv . You have been a life saver.

User avatar
New member

Posts

Joined
Sun Feb 06, 2011 6:08 am

Post by justinv » Mon Feb 07, 2011 7:31 am

No worries. For what it's worth, I think the first one would've worked if we'd applied the same fix that we did to yours:

Code: Select all

if (isset($this->request->get['route'])) {
    $this->data['route'] = $this->request->get['route'];
}
else {
   $this->data['route'] = '';
}

Documentation: OpenCart User Guide
Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN
Image


Active Member

Posts

Joined
Tue Oct 12, 2010 1:24 pm

Post by SXGuy » Fri Feb 11, 2011 9:35 pm

Ive have tried what you have suggested to hide cart module, placing code in both the controller/cart.php and view/cart.tpl

but the cart module is shown on every page still.

Im using 1.4.9.3

What am i missing? am i ment to disable the cart module in the backend?

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by scott23 » Fri Feb 11, 2011 10:02 pm

SXGuy,

What pages are you attempting to hide the cart on?

Scott

User avatar
New member

Posts

Joined
Sun Feb 06, 2011 6:08 am

Post by SXGuy » Fri Feb 11, 2011 10:58 pm

I wish to hide the cart on all information pages, and only show the cart on the category and/or product pages.

I will also adapt it to hide the info module on all category/product pages.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by scott23 » Fri Feb 11, 2011 11:40 pm

SXGuy,

Put this in line 1 of the cart.tpl

Code: Select all

<?php if (isset($this->request->get['route']) && ($this->request->get['route'] == 'product/product' || $this->request->get['route'] == 'product/category')) { ?>
and then put this around line 40

Code: Select all

<?php } else { ?>
<?php } ?>
should be right after this code

Code: Select all

 <div class="bottom">&nbsp;</div>
</div>
That should hide the cart on all page but the product and category page.

Scott

User avatar
New member

Posts

Joined
Sun Feb 06, 2011 6:08 am

Post by SXGuy » Sat Feb 12, 2011 1:10 am

Yes, this works, thank you!

I think i must have been doing something wrong :S lol

Anyway thank you.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by triapos » Thu Jun 23, 2011 6:21 am

Hi, this is a good solution
how can do this for subcategory pages can i identify to path
like category_id=35_42_13 or similar
Could you help me please

Newbie

Posts

Joined
Sat Jun 18, 2011 4:35 am

Post by scott23 » Thu Jun 23, 2011 6:35 am

triapos wrote:Hi, this is a good solution
how can do this for subcategory pages can i identify to path
like category_id=35_42_13 or similar
Could you help me please
That should work as long as the route is equal to what is showing on the page in the address bar, just copy whatever is after "route=". I haven't ever tested it using a specific page and I am now testing on 1.5 which has these settings in the Admin section.

Scott

User avatar
New member

Posts

Joined
Sun Feb 06, 2011 6:08 am

Post by triapos » Thu Jun 23, 2011 4:39 pm

Thanks Scott
i try this 1.4.95 in example

Code: Select all

get['route'] == 'product/categoryid&path=12')
did not work for me may be my mistake

Newbie

Posts

Joined
Sat Jun 18, 2011 4:35 am

Post by SXGuy » Thu Jun 23, 2011 8:11 pm

im afraid it is your mistake yes :)

try this

Code: Select all

get['route'] == 'product/category&path=12')

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by scott23 » Thu Jun 23, 2011 8:50 pm

I attempted this on a demo site that I still had out there for 1.4.9.5 but it does not work. I'm guessing that the path variable is passed after the route is checked so therefore it does not see that this is the correct page. If you put in just product/product it will hide it on the product pages.

User avatar
New member

Posts

Joined
Sun Feb 06, 2011 6:08 am

Post by triapos » Fri Jul 08, 2011 4:23 am

Well finally i solved it :)

Code: Select all

<?php if ($category_id ==64 or $category_id==66 or $category_id==67){ ?>
dont forget the use bracket for closing code
However i want to thanks Scott and SXGuy for opinion and quick reply these are very helpfull for me
Thanks again

Newbie

Posts

Joined
Sat Jun 18, 2011 4:35 am

Post by SXGuy » Fri Jul 08, 2011 5:25 pm

i didnt know you could use "or" learn something new every day

You can do it like this

Code: Select all

<?php if ($category_id ==64 || $category_id==66 || $category_id==67){ ?>
as far as i know.

Active Member

Posts

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

Users browsing this forum: No registered users and 4 guests