Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smiley helper codeigniter

I am using codeigniter smiley helper and when i click image it insert just simbols like :) in textarea not image I want that it should show image when i click image. I search on net and find some plugin 'TinyMCE' bt i want to use codeigniter library. pleasse help me.

 <?php $this->load->library('table');

 $image_array = get_clickable_smileys(base_url().'img/smileys/', 'a');

 $col_array = $this->table->make_columns($image_array, 8);

$data1['smiley_table'] = $this->table->generate($col_array);?>  

<?php echo smiley_js(); ?>
<textarea id='a'></textarea><p>Click to insert a smiley!</p>

<?php echo $data1['smiley_table']; ?>

1 Answers

Smiley Helper

Smiley helper can be loaded using the following code:

$this->load->helper('smiley');

The Controller

In your application/controllers/ folder, create a file called smileys.php and place the code below in it.

Important: Change the URL in the get_clickable_smileys() function below so that it points to your smiley folder.

<?php

class Smileys extends CI_Controller {

function __construct()
{
    parent::__construct();
}

function index()
{
    $this->load->helper('smiley');
    $this->load->library('table');

    $image_array = get_clickable_smileys('http://example.com/images/smileys/', 'comments');

    $col_array = $this->table->make_columns($image_array, 8);

    $data['smiley_table'] = $this->table->generate($col_array);

    $this->load->view('smiley_view', $data);
}

}

?>

In your application/views/ folder, create a file called smiley_view.php and place this code in it:


  <html>
<head>
<title>Smileys</title>

<?php echo smiley_js(); ?>

</head>
<body>

<form name="blog">
<textarea name="comments" id="comments" cols="40" rows="4"></textarea>
</form>

<p>Click to insert a smiley!</p>

<?php echo $smiley_table; ?>

</body>
</html>

When you have created the above controller and view, load it by visiting http://www.example.com/index.php/smileys/

like image 85
Nikz Avatar answered Mar 25 '26 07:03

Nikz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!