Extending DatabaseItemList
Permalink
I would like to make use of the DatabaseItemList, bit cannot find a decent tutorial any place. I have managed to extend the item easily enough and can retrieve the pagination and summary info. But how do I display the results? Should I write custom code for displaying of the results?
Also, how do I display the search box? Is it possible to use this search box.
I am really quite confused on this spesific piece of functionality.
Also, how do I display the search box? Is it possible to use this search box.
I am really quite confused on this spesific piece of functionality.
I was hoping it could help me recreate a screen similar to the example attached.
So I have managed to create the ui quite easily by copying and pasting the elements from another single page. I am however still in the dark o how I can change the query to include only results dependent on my search keyword. I tried using , but the DatabaseItemList keeps adding to the back of my query, thus breaking it.
Another thing that I can not sort out is, my pagination displays correctly and it works perfectly, but the summary keeps displaying information of the first page. It does not seem to update dependent on the current page. Any ideas?
addToQuery()
WHERE 1=1
Another thing that I can not sort out is, my pagination displays correctly and it works perfectly, but the summary keeps displaying information of the first page. It does not seem to update dependent on the current page. Any ideas?
Ok, found out I can use the following code to apply the search.
$ul->filter('pTitle', "%keyword%", "LIKE");
I'm nuts busy but you seem to still be plugging away so maybe this will help.
On DatabaseItemList
You can check the apihttp://www.concrete5.org/api/ which is a little hard to navigate but under utilities it shows the methods you can use with DatabaseItemList, also see ItemList etc.
On DatabaseItemList
$dl = new DatabaseItemList(); // this is the start select and join if needed $dl->addToQuery('select something from sometable'); // this is a where with like(can also do like =, < etc) $dl->filter('somecolumn', 'somevalue', 'like'); // Order $dl->sortBy('somecolumn', 'asc'); // get 20 starting with the 10 $results = $dl->get(10, 20); foreach($results as $result) { // do your thing }
You can check the apihttp://www.concrete5.org/api/ which is a little hard to navigate but under utilities it shows the methods you can use with DatabaseItemList, also see ItemList etc.
What is it exactly you're trying to do?
And what do you mean "display the search box"? What search box? If you mean the built-in "Search" block, you just add the block to a page.