codeigniter, php, mysql, xhtml, css, jquery, flex web-development blog
codeigniter
codeigniter: facebook social plugin – like button helper
Jun 20th
Hello everybody,
I have just created a short helper to create facebook like button dynamically for any content, by just giving-in the URL of the page. Hope this one also helps you like my other helpers
Helper function:
-
-
function facebook_like($url){
-
$formlink=‘<iframe src="http://www.facebook.com/plugins/like.php?href=’;
-
$formlink .= ‘;layout=button_count&show_faces=true&width=450&action=like&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px;" allowTransparency="true"></iframe>’;
-
-
return $formlink;
-
}
-
}
-
Usage:
-
-
<?php
-
$url = current_url();
-
?>
-
Note:
As you can see the function requires you to use the codeigniter’s native URI helper.
Codeigniter: Helper – absolute path helper
May 12th
Recently I decided to give some more time to my blog and write some short but interesting posts. I will be writing some posts about custom helper functions that I have written which helps me in application development.
First on the list is a absolute path helper which creates an absolute path, relative to the base of the application. I call this function base_path(‘relative/url’);
-
function base_path($relative_path_location){
-
return base_url().$relative_path_location;
-
}
-
}
The above is the code which will go into your helper file. The function formulates an absolute url from the given relative path based on base path of the application directory. It uses the existing base_url() helper function in codeigniter. So, you have make sure the URL helper is already loaded.
Example:
Suppose you want to tag an image which is located at “application-root/images/picture.jpg” to give its absolute URL in the img tag you can type as follows in your template/view file.
-
<img src="<?php echo base_path(‘images/picture.jpg’);?>" alt="picture"/>
If you application is hosted at domain.com then it will give http://www.domain.com/images/picture.jpg as the returned path where http://www.domain.com/ is the base_url();
thanks,
thephpx
PHP Simple HTML DOM Parser, Codeigniter Integration
Oct 25th
Hi all,
I came across “Simple HTML DOM Parser” recently that allows jQuery like DOM selection. This function is quite handy to do some kungfoo DOM manipulation on the fly!
I needed to use it on codeIgniter so modified the files and integrated it into a single codeIgniter library. The original files can be accessed from here its sourceforge project page. For the codeigniter version of the library click here.
-
$this->load->library(‘domparser’);
-
$html = $this->domparser->file_get_html(‘http://www.google.com/’);
-
$rank = $html->find(‘b.gb1′);
-
For further utility functions of the DOM parser visit this link.
Feel free to comment or contact me directly for any query.
take care,
thephpx