News:

Support the VirtueMart project and become a member

Main Menu

[solved] Browse view is rendered before module - why?

Started by gba, September 10, 2014, 15:15:32 PM

Previous topic - Next topic

gba

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

balai

Hi

Joomla executes first the component and then the modules.
This is joomla

gba

In this case I need the module code be run first.
How can I achieve this?

Best regards,
Gerald

jenkinhill

Rewrite the Joomla core?  You should ask this on the Joomla forum to see if anyone has any tips.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

balai

Or you can write a component which will generate the module's markup and call this with ajax after the page is loaded

gba

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

balai

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

gba

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