VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: saviB on October 22, 2012, 21:59:08 PM

Title: How to Modify the Sort By Layout In Category
Post by: saviB on October 22, 2012, 21:59:08 PM
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?
Title: Re: How to Modify the Sort By Layout In Category
Post by: jasonmccullars on October 22, 2012, 22:37:24 PM
any luck on this?
Title: Re: How to Modify the Sort By Layout In Category
Post by: 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
Title: Re: How to Modify the Sort By Layout In Category
Post by: saviB on October 23, 2012, 21:02:27 PM
Looks like a good work around - Thanks! I'd still like to know what file is setting the Sort By up. VM team?
Title: Re: How to Modify the Sort By Layout In Category
Post by: bytelord on October 23, 2012, 23:08:42 PM
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
Title: Re: How to Modify the Sort By Layout In Category
Post by: lipes on October 23, 2012, 23:48:38 PM
Humm.. so it's possible to we decompose the default Order/Sort by into something like the image (http://img37.imageshack.us/img37/9969/updown.jpg) 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 ?
Title: Re: How to Modify the Sort By Layout In Category
Post by: saviB on October 24, 2012, 15:47:56 PM
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.
Title: Re: How to Modify the Sort By Layout In Category
Post by: jasonmccullars on October 24, 2012, 21:24:46 PM
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).
Title: Re: How to Modify the Sort By Layout In Category
Post by: bytelord on October 25, 2012, 00:14:07 AM
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
Title: Re: How to Modify the Sort By Layout In Category
Post by: get27 on August 15, 2013, 18:11:50 PM
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 ?
Title: Re: How to Modify the Sort By Layout In Category
Post by: Maxim Pishnyak on August 21, 2013, 16:23:39 PM
In template override for category and in css file for VM.