News:

Looking for documentation? Take a look on our wiki

Main Menu

ordering problems 3.2.14

Started by d0ublezer0, September 14, 2018, 11:21:59 AM

Previous topic - Next topic

d0ublezer0

i want to stylize my ordering block with normal up/down ordering icons like this

instead of +/- signs by default, they looks uninformative

in product model i found function, that build html:
function getOrderByList ($virtuemart_category_id = FALSE)

also i found a notice near them:
* notice by Max Milbers html tags should never be in a model. This function should be moved to a helper or simular,...
How many years it is still here?

There is the problem one: changes with this file will be overwrited on next update.
it would be a normal solution to just pass an array of values from product model, you do not need to include the html code  >:(

So, to avoid this, i copied this function to my template
\html\com_virtuemart\category\default.php
and changed html and stylization in a new place

And than i found problem two: ordering won't work on some fields.
for example at product_in_stock
jRoute brokes url like this:
https://sitename/nb-parts/matrix/10-1/by,%60p%60.product_in_stock/dirDesc?keyword=

because field name is `p`.product_in_stock

commenting $orderby = $productModel->checkFilterOrder ($orderby); solves problem for me but i think it is not normal

please do a normal sorting at last!
you force developers to spend hours searching for solutions and workarounds. It's not free.

d0ublezer0

Also what is this in function getOrderByList?
$dotps = strrpos($field, '.');
            if ($dotps !== FALSE) {
                $prefix = substr($field, 0, $dotps + 1);
                $fieldWithoutPrefix = substr($field, $dotps + 1);

            } else {
                $prefix = '';
                $fieldWithoutPrefix = $field;
            }

and after 3 lines:
$field = explode('.', $field);
            if (isset($field[1])) {
                $field = $field[1];
            } else {
                $field = $field[0];
            }

so $fieldWithoutPrefix and $field will be always the same on next lines
for what it was necessary to do two transformations?