News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

How to Modify the Sort By Layout In Category

Started by saviB, October 22, 2012, 21:59:08 PM

Previous topic - Next topic

saviB

Hi folks. I found several posts on how to remove the Sort By - but none on how to edit its layout. Currently, Sort By displays a so:

Sort By:
(sort by drop down menu)

I want it to display as so:

Sort By: (sort by drop down menu)

I believe <?php echo $this->orderByList['orderby'];  ?> Is pulling this from a different file - but I haven't been able to find it. Help?


bytelord

hey guys,

I have made the following to accomplish that:

1. I use CSS to hide the title that is not displaying in line (this will hide both orderby & manufacturer label title)
2. Override CSS to be displayed inline:

.orderlistcontainer {
    display: inline-block;
}

.orderlistcontainer .title {
display:none;
}

3. Change to the following code to add the orderby title:

<div class="orderby-displaynumber">
<div class="width58 floatleft">
<?php echo JText::_('COM_VIRTUEMART_ORDERBY').': '.$this->orderByList['orderby']; ?>
<?php echo $this->orderByList['manufacturer']; ?>
</div>
<div class="width34 floatleft left display-number" style="margin-top:1px;text-align:left!important"><?php echo $this->vmPagination->getResultsCounter();?> <?php echo $this->vmPagination->getLimitBox(); ?></div>
<div id="bottom-pagination">
<?php echo $this->vmPagination->getPagesLinks(); ?>
<span style="float:right"><?php echo $this->vmPagination->getPagesCounter(); ?></span>
</div>

<div class="clear"></div>
</div>


Not sure if on the above code you will find any "code" part or changes that are not same as original, please read it and do not apply the code as it is but only the part you need.

You could use str_replace also (http://php.net/manual/en/function.str-replace.php) to accomplish that.

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

saviB

Looks like a good work around - Thanks! I'd still like to know what file is setting the Sort By up. VM team?

bytelord

#4
Hello,

The function is inside product model (administrator\components\com_virtuemart\models\product.php) @line 1661, function getOrderByList ($virtuemart_category_id = FALSE)

is called by the view (for example for category is called from (components\com_virtuemart\views\category\view.htm.php @line 195), $orderByList = $productModel->getOrderByList($categoryId)

After from your template you use:

echo $this->orderByList['orderby'];

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

lipes

#5
Humm.. so it's possible to we decompose the default Order/Sort by into something like the image without hack the code of core files?
Or we'll have to do many changes in core files to separate the default Order/Sort by system price, manufacturer (etc) from A->Z or Z->A , 0->9 or 9->0 ?
VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

saviB

Thanks bytelord! I'll play around with that. It seems that others are interested in this too. Personally, I wish the Sort By: title was in a different div from the sort by drop menu. That would make it easier to modify in the default.php - and leave the core alone. Maybe something for the future VM team? I know it sounds trivial - but clients ALWAYS get hung up on the trivial. And - they never understand the warning - "well, that requires core changes that can be overwritten if not paid attention to..."

Lipes - thats a good looking option.

jasonmccullars

I'm using VM 2.0.10, joomla 2.5.6.  is there anyway to set the default sort order by price to show highest to lowest (descending)?  If so, what file do I manipulate?  my customer wants his products to be sorted by highest priced items first.  currently the default sort order is ascending (lowest to highest).

bytelord

#8
Hi,


@jasonmccullars: try to play with that one (core changes): http://forum.virtuemart.net/index.php?topic=102590.msg355860#msg355860
@lipes i think can be done the first part but need some str_replace sure but maybe and some js maybe ... not sure. The second one needs to rewrite that function i suppose on the core.
@saviB: the above solution i suggest does not contain any core hacks, but as you mention there are seperated already into divs, look here:

$orderByList = '<div class="orderlistcontainer"><div class="title">' . JText::_ ('COM_VIRTUEMART_ORDERBY') . '</div><div class="activeOrder"><a title="' . $orderTxt . '" href="' . $link . '">' . JText::_ ('COM_VIRTUEMART_SEARCH_ORDER_' . $orderby) . ' ' . $orderTxt . '</a></div>';
$orderByList .= $orderByLink . '</div>';

you could use css to display them inline, using float attribute but need some more work to place the container on the same view

e.g.

.orderlistcontainer .title {
float:left;
}

.orderlistcontainer div.activeOrder {
float:left;
}

.orderlistcontainer div.orderlist {
margin-left: 38px;
margin-top: 19px;
}

That will works also

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

get27

Quote from: bytelord on October 23, 2012, 05:45:32 AM
hey guys,

I have made the following to accomplish that:

1. I use CSS to hide the title that is not displaying in line (this will hide both orderby & manufacturer label title)
2. Override CSS to be displayed inline:

.orderlistcontainer {
    display: inline-block;
}

.orderlistcontainer .title {
display:none;
}

3. Change to the following code to add the orderby title:

<div class="orderby-displaynumber">
<div class="width58 floatleft">
<?php echo JText::_('COM_VIRTUEMART_ORDERBY').': '.$this->orderByList['orderby']; ?>
<?php echo $this->orderByList['manufacturer']; ?>
</div>
<div class="width34 floatleft left display-number" style="margin-top:1px;text-align:left!important"><?php echo $this->vmPagination->getResultsCounter();?> <?php echo $this->vmPagination->getLimitBox(); ?></div>
<div id="bottom-pagination">
<?php echo $this->vmPagination->getPagesLinks(); ?>
<span style="float:right"><?php echo $this->vmPagination->getPagesCounter(); ?></span>
</div>

<div class="clear"></div>
</div>


Not sure if on the above code you will find any "code" part or changes that are not same as original, please read it and do not apply the code as it is but only the part you need.

You could use str_replace also (http://php.net/manual/en/function.str-replace.php) to accomplish that.

Regards

In wich file must I change the code ?
Joomla 2.5.7    Vm 2.0.20

Maxim Pishnyak

In template override for category and in css file for VM.
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart