Joomla component - list view admin page - search is not working -



Joomla component - list view admin page - search is not working -

in joomla 3.x component have list view admin page, added search tools:

<div class="filter-search btn-group pull-left"> <label for="filter_search" class="element-invisible"><?php echo jtext::_('jsearch_filter');?></label> <input type="text" name="filter_search" id="filter_search" placeholder="<?php echo jtext::_('jsearch_filter'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" title="<?php echo jtext::_('jsearch_filter'); ?>" /> </div> <div class="btn-group pull-left"> <button class="btn hastooltip" type="submit" title="<?php echo jtext::_('jsearch_filter_submit'); ?>"><i class="icon-search"></i></button> <button class="btn hastooltip" id="clear-search-button" type="button" title="<?php echo jtext::_('jsearch_filter_clear'); ?>"><i class="icon-remove"></i></button> </div>

but it's not working. how , should add together back upwards search? suppose should add together actions model?

i want search working on (2 out of 7) columns of datatable.

update:

in model's file in populatestate method have:

// load filter state. $search = $app->getuserstatefromrequest($this->context . '.filter.search', 'filter_search'); $this->setstate('filter.search', $search);

and in getlistquery method:

// filter search in title $search = $this->getstate('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.email = ' . $search ); } else { $search = $db->quote('%' . $db->escape($search, true) . '%'); } }

update 2:

ok, managed create search work me. don't know why of default joomla syntax broke search.

effectively, commenting out elements getlistquery in model file , adding proper where clause did trick:

// filter search in title $search = $this->getstate('filter.search'); if (!empty($search)) { //if (stripos($search, 'email:') === 0) { $query->where('a.email "%' . $search .'%" or a.imie "%'.$search.'%"' ); // } else { // $search = $db->quote('%' . $db->escape($search, true) . '%'); // // } }

so i'm upholding bounty 1 explain why had comment these sections getlistquery

since list view in joomla. main content populates list comes corresponding model file.

if standard joomla component, there function name getlistquery() in it.

go ahead , add together code on there. example:

$search = $this->getstate('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $db->quote('%' . $db->escape($search, true) . '%'); //the previous line or straight $query->where('somecolumn ' . $db->quote('%' . $db->escape($search, true) . '%')); } }

also add together in populatestate

// load filter state. $search = $app->getuserstatefromrequest($this->context . '.filter.search', 'filter_search'); $this->setstate('filter.search', $search);

this set variables in state. , done.

update: reply should

$search = $this->getstate('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $db->quote('%' . $db->escape($search, true) . '%'); $query->where('a.email ' . $search .' or a.imie '.$search ); } }

explanation:

normally "search" considered mutual search field list view. normally, works of columns, instead of creating separate search boxes all, recommended maintain single 1 mutual purpose of searching columns.

now, depends on user searched. default joomla users utilize above code.

in if "id:3" searched, go in if part since "id:" mentioned, if part becomes true , search id (which homecoming row id 3). in normal cases, automatically go else part.

finally, these standard practices. if write condition, code work. selection yours.

joomla components

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -