Author Topic: preventing module display on product display  (Read 2816 times)

welrachid

  • Jr. Member
  • **
  • Posts: 265
  • 3rd party plugin developer
  • Skype Name: wel.rachid
  • VirtueMart Version: Always LATEST stable
preventing module display on product display
« on: December 14, 2017, 23:30:24 pm »
Hi
i have a page that is a category layout page. This page is also the "home page".
On this page i have a front-page slider. beneath i have products listed.
When i click products i dont want the slider to be shown.
I have made it so that the slider is only visible on the "home page", but still it is displayed on the product pages.
How can i resolve this?

Thanks
Best regards,
Wel

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4668
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: preventing module display on product display
« Reply #1 on: December 16, 2017, 02:52:09 am »
The solution is to add menu link for each main categories, so you can disable module display for this menus.

Another solution is to check with PHP for view=productdetail.

The ultimate solution is to check for view="virtuemart" and option='com_vituemart', max will remove this view but it's so easy when you use  view=virtuemart as root to set a complete different render as categories because you have in other case to overrides categories and it's more work.

welrachid

  • Jr. Member
  • **
  • Posts: 265
  • 3rd party plugin developer
  • Skype Name: wel.rachid
  • VirtueMart Version: Always LATEST stable
Re: preventing module display on product display
« Reply #2 on: December 16, 2017, 14:09:09 pm »
THX but the whole slider part is not part of the categories view. It's a module Position in the template itself. Therefore it's printer before we even get to the component. Doing if else etc outside of virtuemart I somehow find wrong. Maybe the solution is to make menu kinks. But that kinda breaks the idea behind mod_virtuemart_categories where I print out categories and uses their aliases as url.
Hmm... Maybe the only solution is to do that if else in the template
Best regards,
Wel

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10638
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.8.8
Re: preventing module display on product display
« Reply #3 on: December 16, 2017, 17:07:16 pm »
If u don't want to make menu items then use something like the advanced menu module or even filter it in the template index.php
there is also  https://www.spiralscripts.co.uk/joomla-modules/vm-modcontroller-pro-detail.html
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4668
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: preventing module display on product display
« Reply #4 on: December 16, 2017, 17:28:21 pm »
welrachid
i see under your name : "3rd party plugin developer" so i have give you the minimum explains.
You have to add a specific position(or use a old one) and filter it if you are in virtuemart productdetails.
This is the fastest and best way, because you have not to use any plugin or other tircks, only check for the view= 'productdetails'.
To get it the shortest code that always work is for eg in  templates/protostar/index.php to hide the left bar.
Code: [Select]
if(JFactory::getApplication()->input->get(view') !=='productdetails') {
if ($this->countModules('position-8')) : ?>
<!-- Begin Sidebar -->
<div id="sidebar" class="span3">
<div class="sidebar-nav">
<jdoc:include type="modules" name="position-8" style="xhtml" />
</div>
</div>
<!-- End Sidebar -->
<?php endif;
}

In protostart $view exist and is set with $view     = $app->input->getCmd('view', '');
so you can simplify it with if($view !=='productdetails') {

welrachid

  • Jr. Member
  • **
  • Posts: 265
  • 3rd party plugin developer
  • Skype Name: wel.rachid
  • VirtueMart Version: Always LATEST stable
Re: preventing module display on product display
« Reply #5 on: December 16, 2017, 23:09:58 pm »
Thanks for your help.
My solution ended up being the one with if else

Code: [Select]
$app = JFactory::getApplication();
$input = $app ->input;
$current_option = $input ->get('option');
$current_view = $input ->get('view');
$current_category_id = $input->get('virtuemart_category_id');
$isFrontPageView = false;
if(
$current_option == "com_virtuemart"
&&
$current_view == "category"
&&
$current_category_id == 0
){
$isFrontPageView = true;
}


Code: [Select]
<?php if ($isFrontPageView && $this->countModules'header-img' )) : ?>
      <div class="header-img">
         <div class="container">
<jdoc:include type="modules" name="header-img" style="xhtml" />
         </div>
      </div>
<?php endif;?>

Yes i do 3rd party plugins, but not officially for sale. i make very specific plugins for clients, that needs something outside normal.
The question i put in this thread was probably a more general Joomla question, but i was hoping that VM had something included i could use.
anyway. Thanks for your guidance.
The slider is only needed on that specific page and therefore i've made the current_category_id == 0
Best regards,
Wel

visitmontaione

  • Beginner
  • *
  • Posts: 46
  • A beginner
Re: preventing module display on product display
« Reply #6 on: November 24, 2022, 21:50:28 pm »
Thanks for your help.
My solution ended up being the one with if else

Code: [Select]
<?php if ($isFrontPageView && $this->countModules'header-img' )) : ?>
      <div class="header-img">
         <div class="container">
<jdoc:include type="modules" name="header-img" style="xhtml" />
         </div>
      </div>
<?php endif;?>

Yes i do 3rd party plugins, but not officially for sale. i make very specific plugins for clients, that needs something outside normal.
The question i put in this thread was probably a more general Joomla question, but i was hoping that VM had something included i could use.
anyway. Thanks for your guidance.
The slider is only needed on that specific page and therefore i've made the current_category_id == 0


Hello welrachid I have exactly your problem.

I have a slider on the top level category (which is also the home page shop).

This slider is repeated in the product details page.

Could you please explain me where this code:


this

Code: [Select]
<?php if ($isFrontPageView && $this->countModules'header-img' )) : ?>
      <div class="header-img">
         <div class="container">
<jdoc:include type="modules" name="header-img" style="xhtml" />
         </div>
      </div>
<?php endif;?>

Will go in the template inde.php right?

Thanks for helping!


Code: [Select]
$app = JFactory::getApplication();
$input = $app ->input;
$current_option = $input ->get('option');
$current_view = $input ->get('view');
$current_category_id = $input->get('virtuemart_category_id');
$isFrontPageView = false;
if(
$current_option == "com_virtuemart"
&&
$current_view == "category"
&&
$current_category_id == 0
){
$isFrontPageView = true;
}

have to be placed?