VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: gba on September 10, 2014, 15:15:32 PM

Title: [solved] Browse view is rendered before module - why?
Post by: gba on September 10, 2014, 15:15:32 PM
Hello VM pros!

I just noticed, that for some reason the product list in the browse view (/components/com_virtuemart/views/category/tmpl/default.php) is rendered before a module (/modules/mod_gmr_load_picture/tmpl/default.php), although this module is rendered in a position before the main content.
Does anyone have any idea why?
And how can I fix this?

Here is the code of the main area of the template (the mentioned module is in 'position-3'):
<main id="content" role="main" class="<?php echo $span?>">
<!-- Begin Content -->
<jdoc:include type="modules" name="position-3" style="xhtml" />
<jdoc:include type="message" />
<jdoc:include type="component" />
<jdoc:include type="modules" name="position-2" style="none" />
<!-- End Content -->
</main>


Maybe the 'jdoc:include's are not run sequentially but concurrently, and the code in the module takes longer than the component code.
If this is the case, how can I make the component code wait until the module code has finished?

Thank you for any useful hint!

Best regards,
Gerald
Title: Re: Browse view is rendered before module - why?
Post by: balai on September 10, 2014, 16:39:38 PM
Hi

Joomla executes first the component and then the modules.
This is joomla
Title: Re: Browse view is rendered before module - why?
Post by: gba on September 10, 2014, 16:41:14 PM
In this case I need the module code be run first.
How can I achieve this?

Best regards,
Gerald
Title: Re: Browse view is rendered before module - why?
Post by: jenkinhill on September 10, 2014, 18:12:23 PM
Rewrite the Joomla core?  You should ask this on the Joomla forum to see if anyone has any tips.
Title: Re: Browse view is rendered before module - why?
Post by: balai on September 11, 2014, 09:45:41 AM
Or you can write a component which will generate the module's markup and call this with ajax after the page is loaded
Title: Re: Browse view is rendered before module - why?
Post by: gba on September 11, 2014, 12:12:59 PM
Hello balai!

Thank you for your constructive hint.
Is it possible to run more than one component on a page?
VM is the component, that is run in my case.

Maybe I should explain more deeply, what I am doing:
- In the module there is a form. Into this form the user enters a certain ID. On submitting this form, I store several values relating to the entered ID in session variables.
- In the VM browse view template I read these session variables to filter the products depending on values of the variables, before they are listed.

The problem is now, that the browse view is rendered even before the module could store the values in the session variables.
Result: The products are not filtered or are filtered based on old values.

You adviced me to
Quotewrite a component which will generate the module's markup and call this with ajax after the page is loaded
.
I'm afraid, I did not understand, what you meant  :-[
Could you, please, explain your approach?

Kind regards,
Gerald
Title: Re: Browse view is rendered before module - why?
Post by: balai on September 11, 2014, 16:52:57 PM
I think that you can solve that by writing a plugin of type vmcustom

You need to have a function named plgVmBeforeProductSearch
This function is triggered before VM returns the products

To check how this is triggered check the function sortSearchListQuery into the file: administrator/components/com_virtuemart/models/product.php

So the approach is that after submitiing your form this will be sent to Virtuemart (option=com_virtuemart).
Then VM will trigger your plugin which will be able to get the form variables you want and format the products query accordingly

You have to be familiar with the php and the development of joomla plugins to do that.
You can get an idea from some search and filtering extensions our there
Title: Re: Browse view is rendered before module - why?
Post by: gba on February 02, 2015, 13:33:14 PM
Hi!

I "solved" the problem including the code, which I used to have in the module, directly into the browseview template file. ;)

Kind regards,
Gerald