Prabin Silwal in Discussion Discussion, jQuery, Php, Wordpress
Auction functionality in word press is using plugins. You may use free plugins or made your own. For making auction sites there are no free auction plugins but there are free E-commerce one, so you can simply modify the E-commerce plugin with your business logic working as auction software.
There is an auction site in which we build using word press. It is price reveal auction site which are working as explained below:
E-SmartStore is a best reveal auction site where you can buy tablets, laptops, smartphones and electronic gadgets after bidding in cheap price.
Prabin Silwal in Discussion Discussion
I want to share jQuery autocomplete function for quick development but within custom template format.
First you should have to know about autocomplete function.
Instead of the user having to type out the full value of the input field each time, the autocomplete widget offers suggestions as to what the value might be.
For example, let’s say you’re adding a new product. The product field could be a text input, a
select input, and so on. In this scenario, one would use the existing product in the system as
the source for an autocomplete widget. Chances are, the user who is entering the product, or
another user for that matter, has entered that product before. With autocompletes, users have
some assurance that they’re providing valid inputs.
The normal autocomplete function example:
<!doctype html><htmllang=”en”><head> <metacharset=”utf-8″> <title>jQuery UI Autocomplete – Default functionality</title> <linkrel=”stylesheet”href=”//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css”> <scriptsrc=”//code.jquery.com/jquery-1.10.2.js”></script> <scriptsrc=”//code.jquery.com/ui/1.11.0/jquery-ui.js”></script> <linkrel=”stylesheet”href=”/resources/demos/style.css”> <script> $(function() { var availableTags = [ “ActionScript”, “AppleScript”, “Asp”, “BASIC”, “C”, “C++”, “Clojure”, “COBOL”, “ColdFusion”, “Erlang”, “Fortran”, “Groovy”, “Haskell”, “Java”, “JavaScript”, “Lisp”, “Perl”, “PHP”, “Python”, “Ruby”, “Scala”, “Scheme” ]; $(“#tags” ).autocomplete({ source: availableTags }); }); </script></head><body><divclass=”ui-widget”> <labelfor=”tags”>Tags:</label> <inputid=”tags”></div> </body></html>
Output:
After having simple understanding of autocomplete, now dive into realtime useful but little complicated example.
Here data I get is by calling controller named ‘ajax_suggest_username_to_tag’ . The controller is getting data from model and is echoed back to view by encoding it to json format.
$(‘.listen_comment_post’).autocomplete({
source : baseurl + ‘tags/index/ajax_suggest_username_to_tag’,
minLength : 1,
select : function (event, ui)
{
console.log(ui);
//$(‘#post_tag’).val(ui.tag_name);
//current_tag_list = $(‘#post_tag_list’).val();
}
}).data(“autocomplete”)._renderItem = function (ul, item) {
var inner_html = ‘<a><div class=”show_user_on_comment”><figure><img height=”30px” src=”‘+item.label+'”></figure><div class=”search_dtail_P”><p class=”user_name”>’+item.username+'</p><p class=”full_name”>’+item.first_name+'</p></div><div class=”clear”></div></div></a>’;
return $(“<li></li>”)
.data(“item.autocomplete”, item)
.append(inner_html)
.appendTo(ul);
};
My PHP code:
Controller:
function ajax_suggest_username_to_tag()
{
$tags_list = $this->tags_model->ajax_suggest_username_to_tag();
print_r(json_encode($tags_list));
die();
}
Model:
public function ajax_suggest_username_to_tag()
{
$cur_member_id = $this->session->userdata(‘current_member_id’);
$q=$this->input->get(‘term’);
$key = $q;
//Old query
//$sql_rees= $this->db->query(“select * from member_login_type where first_name like ‘%$q%’ or last_name like ‘%$q%’ order by member_id LIMIT 5”);
//New query updated 04-02-2014
$sql_rees= $this->db->query(“select * from member_login_type where member_id != $cur_member_id and login_status = ‘active’ and ((first_name like ‘%$q%’ or last_name like ‘%$q%’) OR (CONCAT(first_name,’ ‘,last_name) like ‘%$q%’) or username like ‘%$q%’) order by member_id LIMIT 5″);
if($sql_rees->num_rows >0)
{
$all_list = array();
$all_result = $sql_rees->result_array();
//START: To be solved by KAMALA JI
// echo ‘<ul>’;
foreach( $all_result as $row)
{
$username = $row[‘username’];
$fname=$row[‘first_name’];
$lname=$row[‘last_name’];
$img=$row[‘profile_image’];
$country=$row[‘address’];
$re_fname='<b>’.$q.'</b>’;
$re_lname='<b>’.$q.'</b>’;
$re_username='<b>’.$q.'</b>’;
$final_fname = str_ireplace($q, $re_fname, $fname);
$final_lname = str_ireplace($q, $re_lname, $lname);
$final_username = str_ireplace($q, $re_username, $username);
// echo ‘<li><a href=”‘.base_url().$username.'”>’;
if(is_file(FCPATH .MEMBER_UPLOAD_THUMBS.’28×26/’.$img))
{
//echo base_url().MEMBER_UPLOAD_THUMBS.’83×73/’.$img;
$profile_image = base_url().MEMBER_UPLOAD_THUMBS.’28×26/’.$img;
}
else
{
//echo IMG_DIR.’no_image.jpg’;
$profile_image = IMG_DIR.’no_image.jpg’;
}
//echo ‘<figure><img height=”30px” src=”‘.base_url().MEMBER_UPLOAD.$img.'”/></figure>’;
// echo ‘<div class=”search_dtail_P”>’;
//echo ‘<p class=”user_name”>’.$final_username.'</p>’;
// echo ‘<p class=”full_name”>’.$final_fname.$final_lname.'</p>’;
// echo ‘<p class=”country”>’.$country.'</p>’.'</div>’;
//echo ‘<div class=”clear”></div></a><li>’;
array_push($all_list,array(“value”=>$username,”username”=>$final_username,”label”=>$profile_image,”first_name”=>$final_fname)); }
return $all_list;
}
return false;
//echo ‘<li><a href=”‘.base_url().’user/search/see_all/’.$q.'”>See All Result for ‘.$q.'</a></li>’;
// echo ‘</ul>’;
}
But I was getting below error:
—————————-ERROR————————
TypeError: $(…).autocomplete(…).data(…) is undefined
}).data(“autocomplete”)._renderItem = function (ul, item) { |
After some research I also found solution as listed below:
——————SOLUTION————————
data(‘ui-Autocomplete’)resolved my troubles.
Hope this article helps you to creating your autocomplete box as in Facebook or other sites.
Prabin Silwal in Discussion Discussion, PHP/MySql/HTML, Wordpress
Every programmer is curious about future trends, and I am not the exceptional one. So, today I am sharing the knowledge that I found about future trends of programming. It’s no secret that technology trends move fast and the tools and means for building those technologies constantly evolve. But if you don’t lift your head up every once in a while to look past the next year’s projects, you could end up coding yourself down an inescapable rabbit hole. Read them quickly because the future is changing faster than we know.
When the browser doesn’t win, Android is close behind. Camera designers, threatened by cellphones with good lenses, started putting Android on cameras, so now you can run Instagram on a Nikon. Does that make Nikon a computer company now? Does it even matter?
There are Android refrigerators, car stereos, watches, televisions, even headphones. Some complain that the UI is too complicated because it can do too much, but that’s missing the point. The UI layer can always be simplified. If Android is running underneath, the platform will dominate.
It’s going to get even more complicated. PC manufacturers are looking at the burgeoning tablet world and feeling left out. Their solution is to run Android on Windows and let people use their Android apps on their desktops, too. Some just run the stock Android emulators used by programmers, but others are looking beyond that to create brands like “PC Plus.” Once Android takes over the PC, it may combine with the browser to push Windows native apps into a distant third place for mindshare on the box.
Android on your refrigerator will mean the opportunity to write code for the refrigerator itself, whether it’s an app for displaying kid art, some calorie-counting scold, or a recipe suggestion engine for what’s left inside the icebox. Who knows?
For all of the success of open source stacks like Android, Ubuntu, or MySQL, there remains a sticky problem with finding the revenue to support development. There are plenty of good stories about how open source code has helped hackers, but there aren’t very many examples of how companies built a relatively stable ecology that lets the programmers buy health care or food.
The vast majority of open-source companies distribute what might better be called a demonstration version under an open-source license. Then some kind of secret sauce is kept locked away to give the programmers something to bargain with. It’s the way of the world. Why buy the cow if you can get the milk for free? The best open source projects will find a way to tighten the screws in a comfortable way without scaring away customers.
It’s the biggest mistake if someone trying to build websites from scratch. No one does that anymore. Why bother when you can add a plug-in to WordPress? If you’re really picky, you could work with Joomla or Drupal. The point isn’t really which platform, just the fact that there are fewer and fewer reasons to create your own Web apps because so much functionality is built into the dominant frameworks.
The game gets even more interesting when you start hacking the code. WordPress has its own editor built into it, so you can do your development inside WordPress, too. There’s no debugger, but you can get around that. If WordPress adds a nice database browser like PHPMyAdmin and provides a bit of basic debugging tools, the development will really accelerate.
Basic Web apps aren’t the only ones riding the power of code snippets that can be plugged into a bigger framework. Photoshop used to be the dominant engine for reworking images, in part because of the fertile world of plug-ins. Now the newer apps like MagicHour have made plug-ins even simpler. MagicHour users, for instance, can share filters just like they share photos. Most major platforms offer a good plug-in API, and the ones with the best have fertile ecologies filled with thousands of modules, libraries, and plug-ins.
This burgeoning ecology for code means that programmers will write more snippets and fewer applications. The right bit of glue code can be a million times more powerful than a great, hand-built application with megabytes of a binary file. A small snippet can leverage everything in the entire ecology. A big app must do everything on its own.
The savvy programmers will learn to leverage this by creating plug-ins, not programs. They’ll learn the APIs for the host systems and string together parts. Very few will ever build anything from scratch.
No, JavaScript won’t be the only language in the programming world. JavaScript is inescapable on the browser, which now dominates almost everything a client computer does. Now the server side is embracing it with tools like Node.js.
JavaScript will assuredly become more dominant in other areas as well. Once the only way into a smartphone was to write code in the native language demanded by the manufacturer: Objective-C for the iPhone; Java for Android; C# for Microsoft. Now, most mobile developers can get the performance they want out of HTML5 applications running in browser-like views. The result may not be as zippy as native code, but the JavaScript is good enough and portable to the Web, too.
The browser isn’t just colonizing phones; it’s eating entire platforms. Chrome OS and Chromebooks are making regular operating systems obsolete. Why worry about that layer when JavaScript and the browser can do everything? The mainframe will have Cobol. Biologists will probably stick with Python. Linux will be written in C. But almost everything else is fair game as JavaScript gobbles the world.