1. Go to this page and download the library: Download yidas/codeigniter-widget library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace app\widgets;
use yidas\Widget;
class Test extends Widget
{
// Customized variable for Widget
public $message;
public function init()
{
// Use $this->CI for accessing Codeigniter object
$baseUrl = $this->CI->config->item('base_url');
if ($this->message === null) {
$this->message = "Your Site: {$baseUrl}";
}
}
public function run()
{
// Render the view `test.php` in `WidgetPath/views` directory,
return $this->render('test', [
'message' => $this->message,
]);
}
}
public string render(string $view, array $variables=[])
public function run()
{
return $this->render('view_name', [
'variable' => $this->property,
]);
}
public function run()
{
// Get data from a model
$this->CI->load->model('Menu_model');
$list = $this->CI->Menu_model->getList();
// Build widget's view with list data
return $this->render('test', [
'list' => $list,
]);
}
html
use app\widgets\Hello;
html
use app\widgets\Hello;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.