News:

Support the VirtueMart project and become a member

Main Menu

OrderBy Layout

Started by isalcedo, January 22, 2013, 17:49:03 PM

Previous topic - Next topic

isalcedo

Hello Folks, Virtuemart have (by Default) with <?php echo $this->orderByList['orderby']; ?> a layout "looks like" a Drop Down <select> Menu, but is a lots of Divs with style and Javascript, is there a way to turn it into a <select><option> Blah </option></select>? My Client is a Huge Fan of MacOs and is freak out about that menu doesnt looks like the others Drop Down <select> menus. Sorry if i cant explain me well, i speak english but not at this level.

PRO

Quote from: isalcedo on January 22, 2013, 17:49:03 PM
Hello Folks, Virtuemart have (by Default) with <?php echo $this->orderByList['orderby']; ?> a layout "looks like" a Drop Down <select> Menu, but is a lots of Divs with style and Javascript, is there a way to turn it into a <select><option> Blah </option></select>? My Client is a Huge Fan of MacOs and is freak out about that menu doesnt looks like the others Drop Down <select> menus. Sorry if i cant explain me well, i speak english but not at this level.


yes there is, you are going to have to code it yourself. (ITS easier doing it with a module) Unless you want to hardcode it in the cat template

Not that hard though. I make my own dropdown with css only.

Just turn off sef, and view source for the parameters. Then build the urls with JRoute
like this
$bestsalesurl=JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$dropcatid.'&Itemid='.$item.'&order=DESC&orderby=product_sales');

You could write a small function to wrap each in the <select>



isalcedo

Oh! Is Done, it took me 40min, last time i couldn't. This is the code, i hope can make Virtuemart a Better Software. :D Thanks a lot.

The file: \Virtuemart 2.XX\com_virtuemart.2.XX\administrator\components\com_virtuemart\models\product.php

Code: For Virtuemart 2.0.14 - From Line 1814

/* order by link list*/
$orderByLink = '';
$fields = VmConfig::get ('browse_orderby_fields');
if (count ($fields) > 1) {
//$orderByLink = '<div class="orderlist">';
foreach ($fields as $field) {
if ($field != $orderby) {

$dotps = strrpos ($field, '.');
if ($dotps !== FALSE) {
$prefix = substr ($field, 0, $dotps + 1);
$fieldWithoutPrefix = substr ($field, $dotps + 1);
// vmdebug('Found dot '.$dotps.' $prefix '.$prefix.'  $fieldWithoutPrefix '.$fieldWithoutPrefix);
}
else {
$prefix = '';
$fieldWithoutPrefix = $field;
}

$text = JText::_ ('COM_VIRTUEMART_' . strtoupper ($fieldWithoutPrefix));

if ($field == $orderbyCfg) {
$link = JRoute::_ ($fieldLink . $manufacturerTxt);
}
else {
$link = JRoute::_ ($fieldLink . $manufacturerTxt . '&orderby=' . $field);
}
$orderByLink .= '<option value="' . $link . '">' . $text . '</option>';
}
}
//$orderByLink .= '</div>';
}

/* invert order value set*/
if ($order == 'ASC') {
$orderlink = '&order=DESC';
$orderTxt = JText::_ ('COM_VIRTUEMART_SEARCH_ORDER_DESC');
}
else {
$orderTxt = JText::_ ('COM_VIRTUEMART_SEARCH_ORDER_ASC');
$orderlink = '';
}

/* full string list */
if ($orderby == '') {
$orderby = $orderbyCfg;
}
$orderby = strtoupper ($orderby);
$link = JRoute::_ ($fieldLink . $orderlink . $orderbyTxt . $manufacturerTxt);

$dotps = strrpos ($orderby, '.');
if ($dotps !== FALSE) {
$prefix = substr ($orderby, 0, $dotps + 1);
$orderby = substr ($orderby, $dotps + 1);
// vmdebug('Found dot '.$dotps.' $prefix '.$prefix.'  $fieldWithoutPrefix '.$fieldWithoutPrefix);
}
else {
$prefix = '';
// $orderby = $orderby;
}

$orderByList = '<div class="orderlistcontainer"><div class="title">' . JText::_ ('COM_VIRTUEMART_ORDERBY') . '</div><select ONCHANGE="location = this.options[this.selectedIndex].value;" class="activeOrder"><option value="' . $link . '">' . JText::_ ('COM_VIRTUEMART_SEARCH_ORDER_' . $orderby) . ' ' . $orderTxt . '</option>'. $orderByLink .'</select>';
$orderByList .= '</div>';


This is Great, Looks Great and same style in all Browsers, Off course, if is a error there, tell me. :)

PRO

thats hacking the core. we do not support it.

Just as easy to do in the template overrides


isalcedo

Oh! How can i override a model from Template? I know how to override modules and other stuff but, models, how?

PRO

you do not override the model. You build the form yourself like I said above

d0ublezer0

Quote* Get the Order By Select List
*
* notice by Max Milbers html tags should never be in a model. This function should be moved to a helper or simular,...
*
Can you remove html code from model, please?
Because of this, many people have to create such inconvenient constructions:
<?
if (!empty($this->orderByList["orderby"]))
{
$order_html = $this->orderByList["orderby"];
$order_html = str_replace(array('title="-/+"','title="-/+"'), "", $order_html);
$order_html = str_replace("-/+", "<i class='fa fa-angle-up'></i>", $order_html);
$order_html = str_replace("+/-", "<i class='fa fa-angle-down'></i>", $order_html);
echo $order_html;
}
?>