onBeforeProductListingLoad() Enhancement
- brainforge
-
Topic Author
- Offline
Less
More
15 years 2 months ago - 15 years 2 months ago #20479
by brainforge
onBeforeProductListingLoad() Enhancement was created by brainforge
Would it be possible to extend the call to this trigger to something like:
Similarly for the onBeforeCategoryListingLoad trigger.
I am implementing a search facility which lists the products using the product list views, not 100% certain I would need to use this information at the moment, but providing it would give direct access to all the information related to the request.
*** After a bit more investigation passing $this into the plug-in would be very useful. Can modify the view template for the Display / Content Menu form (e.g. add a searchable parameter to it) which can then be checked for in the plug-in.
Code:
$dispatcher->trigger( 'onBeforeProductListingLoad', array( & $filters, & $order, & $this) );
I am implementing a search facility which lists the products using the product list views, not 100% certain I would need to use this information at the moment, but providing it would give direct access to all the information related to the request.
*** After a bit more investigation passing $this into the plug-in would be very useful. Can modify the view template for the Display / Content Menu form (e.g. add a searchable parameter to it) which can then be checked for in the plug-in.
Last edit: 15 years 2 months ago by brainforge. Reason: Added note about Content Menu form
Please Log in or Create an account to join the conversation.
15 years 2 months ago #20511
by nicolas
Replied by nicolas on topic Re: onBeforeProductListingLoad() Enhancement
There are some problems with that:
1. The $this of the category trigger and of the product trigger are not the same. So it's not consistent.
2. The existing plugins which already implement these triggers will crash if called with these additional parameters if the persons developing them don't modify their code. So doing that would hinder backward compatibility.
But I see the possible applications of adding such parameters in the trigger and that indeed sound interesting.
Do you have any suggestions regarding these points ?
1. The $this of the category trigger and of the product trigger are not the same. So it's not consistent.
2. The existing plugins which already implement these triggers will crash if called with these additional parameters if the persons developing them don't modify their code. So doing that would hinder backward compatibility.
But I see the possible applications of adding such parameters in the trigger and that indeed sound interesting.
Do you have any suggestions regarding these points ?
Please Log in or Create an account to join the conversation.
- brainforge
-
Topic Author
- Offline
15 years 2 months ago #20514
by brainforge
Replied by brainforge on topic Re: onBeforeProductListingLoad() Enhancement
1. The 2 triggers are different, so would not be an issue.
In the plugin the functions could be defined as:
2. In my installations (currently 5.3) PHP handles variable parameters lists with additional parameters being ignored by the interpreter. Only if one where to be removed would there be a problem.
I have tested this with the following code and it worked fine:
The searchable parameter is an additional field I put into my template view override for the menu form.php file.
In the plugin the functions could be defined as:
Code:
function onBeforeProductListingLoad(&$filters, &$order, &$productView){...}
function onBeforeProductListingLoad(&$filters, &$order, &$categoryView){...}
2. In my installations (currently 5.3) PHP handles variable parameters lists with additional parameters being ignored by the interpreter. Only if one where to be removed would there be a problem.
I have tested this with the following code and it worked fine:
Code:
...
$dispatcher->trigger( 'onBeforeProductListingLoad', array( & $filters, & $order, & $this) );
...
Code:
class plgHikashopBf_Search extends JPlugin{
// function onBeforeProductListingLoad(&$filters, &$order, &$view) {
// $searchable = trim($view->params->get('searchable'));
// if (empty($searchable)) return;
function onBeforeProductListingLoad(&$filters) {
$searchable = 'product_name,product_description';
...
}
}
Please Log in or Create an account to join the conversation.
15 years 2 months ago #20542
by nicolas
Replied by nicolas on topic Re: onBeforeProductListingLoad() Enhancement
Great then. We'll do that.
Please Log in or Create an account to join the conversation.
- brainforge
-
Topic Author
- Offline
15 years 2 months ago #20555
by brainforge
Replied by brainforge on topic Re: onBeforeProductListingLoad() Enhancement
Thanks.
Please Log in or Create an account to join the conversation.
- brainforge
-
Topic Author
- Offline
15 years 2 months ago #20629
by brainforge
Replied by brainforge on topic Re: onBeforeProductListingLoad() Enhancement
Just realised that the 'onBeforeProductListingLoad' trigger is called from the administration screens as well as the site screens.
The change:
needs to be made to views/product/view.html.php in both places please.
Also, although I am not using it, I looked for the call to 'onBeforeCategoryListingLoad' and found it in classes/category.php rather than views/category/view.html.php. Does not really matter as long as in gets called in the same manner
.
The change:
Code:
$dispatcher->trigger( 'onBeforeProductListingLoad', array( & $filters, & $order, & $this) );
Also, although I am not using it, I looked for the call to 'onBeforeCategoryListingLoad' and found it in classes/category.php rather than views/category/view.html.php. Does not really matter as long as in gets called in the same manner
Code:
$dispatcher->trigger( 'onBeforeCategoryListingLoad', array( & $filters, & $order, & $this) );
Please Log in or Create an account to join the conversation.
15 years 2 months ago #20635
by nicolas
Replied by nicolas on topic Re: onBeforeProductListingLoad() Enhancement
Yes. We already made the change everywhere.
Please Log in or Create an account to join the conversation.
- brainforge
-
Topic Author
- Offline
15 years 2 months ago #20649
by brainforge
Replied by brainforge on topic Re: onBeforeProductListingLoad() Enhancement
Thanks.
Please Log in or Create an account to join the conversation.
Time to create page: 0.235 seconds