Some words about FB autosuggest plugin’s source code

Firs I have to tell you that I am not a good writer. :)

The name of the plugin comes from the facebook autosugeest because it gives your blog the facebook style of search.

What can you customize?

In the file fb_autosuggest.php , from line 12 to 51 is the code used for give the serch results

$fb_action = ”; //initialize the variable which will receive the action (not important)
$fb_keys = ”; //initialize the variable to store the search string
if(isset($_GET['fb_action'])) { //if the action is set
$fb_action = $_GET['fb_action']; //then the variable will receive the action from the GET
}
if (isset($_GET['fb_query'])) { //if the search string is received in GET
$fb_keys = $_GET['fb_query']; //then value will be stored in $fb_keys
}if ($fb_action == ‘query’) { //if the action is query, the we will prepare the resultsrequire_once (‘../../../wp-config.php’);global $wpdb;

$fb_keys = str_replace(‘ ‘,’%',$fb_keys); //separate the words by % to search for the words, not for the exact expression
$pageposts = $wpdb->get_results(“SELECT * FROM $wpdb->posts WHERE (post_title LIKE ‘%$fb_keys%’ or post_content LIKE ‘%$fb_keys%’) AND post_status = ‘publish’ ORDER BY post_date DESC limit “.get_fb_option(‘fb_maxresults’,20)); //search in the database
//this query will search in the title and in the content of the posts order by date desc and with a limit set in Max Results (default is 20)
$chars=get_fb_option(‘fb_chars’,100); //here we are getting how many chars will be displayed from the content of the post, default is 100

foreach ($pageposts as $post) { //fo each post we will display the result
setup_postdata($post);
?>
<div id=”ellist”> //div of each result, it is important to have the id=”ellist”, in this div you can change as you want to display the results
<a href=”<?=the_permalink()?>” class=”ev”> //here is the link to follow when the reader cliks on result or when pres enter on a selected result
<?=the_post_thumbnail(‘thumbnail’)?> //here we are displayng the post thumbnail
<b> <?=the_title()?> </b> <br> //displayng the title of the thumbnail
<?=mb_substr(strip_tags( get_the_content(),’<br><b><strong><i>’),0,$chars)?>… //diaplay an excerpt of the post content
</a>
</div>
//before and after this div you can display anything you want, important is that if the div is a selectable result, to set the id=”ellist” and for the action to set class=”ev” and in href of the anchor what link to follow

<?php
}

die();
}

 

If you want to change the styles, you can make changes in fb_autosuggestion.css, located in css folder.

 

Posted in Uncategorized | Leave a comment

More details About FB-Autosuggest plugin

This is my first plugin for wordpress.

The script is inspired from Abdel-Rahman Awad script and it uses jQuery framework.

Also, being my first plugin, it  was inspired from wp-autosuggest plugin.

For instalation you can download, unzip the archive, copy the folder ‘fb-autosuggest’ in ‘/wp-content/plugins/’ and then activate it from the wp panel. It is very simple and you can install and use it in seconds.
Feel free to use end enjoy its benefits!

In the next post I will explain the source code.

 

Posted in Uncategorized | 1 Comment

Later

I will come with other details and description for the plugin.

If you  have questions please leave comments.

Posted in Uncategorized | 2 Comments

FB-Autosuggest

FB-Autosuggest (click to download)


Requires at least: 2.7

Tested up to: 3.2.1 Stable tag: 1

_________

FB AutoSuggest brings the power and style of facebook frined search to your WordPress blog.

________

- Installation Installing FB AutoSuggest is very easy: 1. Upload ‘fb-autosuggest’ to the ‘/wp-content/plugins/’ directory 1. Activate the plugin through the ‘Plugins’ menu in WordPress
____________

You can cutomize some options from FB-autosuggest settings page

1. If the searchbox id is other than ‘s’ you have to change to the serchbox id in your theme

2. You want more or less than 20 results, you can change Max Results

3. The width of the div where the results are displayed can be change from ‘Div width for serch results’, the width is in pixels

4. If the div with the results is to close or to far from the seachbox, you can change in ‘Margin-top of div results’

5. You also can change Number of characters to be displayed from the post content

Posted in Uncategorized | 3 Comments

Another test post

This is only a test post to check the search plugin.

Posted in Uncategorized | Leave a comment

Search Autosuggestion plugin for blogs – Facebook serch style

IF YOU WANT TO IMPLEMENT IN YOUR BLOG THE AUTOSUGGETIONS FOR SEARCH LIKE FACEBOOK STYLE, FOLOW THIS BLOG AND YOU WILL FIND THE PLUGIN VERY SOON.

Posted in Uncategorized | Leave a comment