By drupalninja99 on
I grabbed some code from book pages and put it in my view argument handling code box. I'm trying to add a sort for the custom CCK field "field_price". I tried this but failed, I don't know how to make the view join that table. I don't really know what I'm doing. Can anyone help?
if ($_GET['sort']== "title") {
$view->sort[0]['position'] = 0;
$view->sort[0]['field'] = 'node.title';
$view->sort[0]['sortorder'] = $_GET['order'];
$view->sort[0]['options'] = '';
$view->sort[0]['tablename'] = '';
$view->sort[0]['id'] = 'node.title';
}
else if ($_GET['sort']== "date") {
$view->sort[0]['position'] = 0;
$view->sort[0]['field'] = 'node.created';
$view->sort[0]['sortorder'] = $_GET['order'];
$view->sort[0]['options'] = '';
$view->sort[0]['tablename'] = '';
$view->sort[0]['id'] = 'node.created';
}
else if ($_GET['sort']== "price") {
$view->sort[0]['position'] = 0;
$view->sort[0]['field'] = 'field_price';
$view->sort[0]['sortorder'] = $_GET['order'];
$view->sort[0]['options'] = '';
$view->sort[0]['tablename'] = '';
$view->sort[0]['id'] = 'field_price';
}
return $args;
Comments
Anybody?
Seems like it should be pretty easy to do, but I can't figure it out. I just need learn how to sort by CCK fields when using views.
does anyone know how to sort by CCK fields when using views???
I know somebody has to know, right? Please help!
I'm trying to do the same
I'm trying to do the same with no joy. Did you ever get this working?
Also, do you still have the handbook page's URL?
uh look in my posts, it's in there somewhere
in another thread i figured it out, search my posts and you should find it -J
Would be nice if you'd update this thread with the solution
I was unable to find the solution searching your other threads. It would be great if you'd take a moment to update this thread with the answer so that people who fins this page through search (like I did) won't be frustrated.
Many thanks!
I think it's here
http://drupal.org/node/265857
Sorry, hope this helps =)
Thanks for updating!
Thanks for updating!