Searching, sorting and paginating items from the database on the dashboard
Permalink 1 user found helpful
I turned the Twitter Streaming API into a c5 package. My huge package displays parsed tweets on dashboard/twitter/feed. Here is the single page's code:
I've attached a grab of the page on the front end.
I'd like to sort the data the way the file manager sorts files. I have no need to delete, edit or add any tweet, only interest in sorting currently hundreds, soon-to-be thousands and eventually hundreds of thousands of tweets. I've read these pages:
http://www.concrete5.org/documentation/developers/system/searching-...
http://www.concrete5.org/community/forums/customizing_c5/simple-exa...
http://www.concrete5.org/community/forums/customizing_c5/database_q...
My huge package should include the following code somewhere. Right?
I just don't know where to put the class or how to call it from the single page. Thanks for your consideration.
<?php defined('C5_EXECUTE') or die("Access Denied."); $db=Loader::db(); $tweet=$db->Execute("SELECT * FROM tweets"); $row=$tweet->FetchRow(); ?> <?php echo Loader::helper('concrete/dashboard')->getDashboardPaneHeaderWrapper(t('Twitter data'))?> <?php if (count($tweet) > 0) { ?> <table class="table table-striped"> <tr> <th width="10%"><?php echo t('Image')?></th> <th width="15%"><?php echo t('User')?></th> <th width="60%"><?php echo t('Tweet')?></th> <th width="15%"><?php echo t('Date')?></th> </tr> <?php foreach($tweet as $tw) { ?> <tr> <td><img src="<?php print $tw['profile_image_url']; ?>" style="width:48px;height:48px" /><input type="hidden" value="<?php print $tw['name']; ?>" /></td> <td><?php print $tw['screen_name']; ?></td> <td><?php print $tw['tweet_text']; ?></td>
Viewing 15 lines of 23 lines. View entire code block.
I've attached a grab of the page on the front end.
I'd like to sort the data the way the file manager sorts files. I have no need to delete, edit or add any tweet, only interest in sorting currently hundreds, soon-to-be thousands and eventually hundreds of thousands of tweets. I've read these pages:
http://www.concrete5.org/documentation/developers/system/searching-...
http://www.concrete5.org/community/forums/customizing_c5/simple-exa...
http://www.concrete5.org/community/forums/customizing_c5/database_q...
My huge package should include the following code somewhere. Right?
Loader::library('item_list'); class TweetList extends DatabaseItemList { public function __construct($query) { $this->setQuery($query); } } $sql = "SELECT * FROM tweets"; $tweets = new TweetList($sql); if ($tweets->getSummary()->pages > 1) { $paginator = $tweets->getPagination(); $pageListing = $paginator->getPages(); } $onePageOfTweets = $tweets->getPage();
I just don't know where to put the class or how to call it from the single page. Thanks for your consideration.
I just put together a boilerplate package for doing search / add / edit / delete functionality for custom objects and custom object lists. It should show where the different files need to live, and how to hook them up with search results using the ajax tools built into the dashboard UI.