Widget plugin (intelligent view partials) |
[eluser]vee[/eluser]
@umefarooq thanks but not that way.. i want it just return value from $this->render() NOT echo without echo. (please try to call widget from topic example without echo and you will know.) ++++++ from this page http://ellislab.com/forums/viewthread/109584/P20/ Quote:Updated Widget plugin for use with Modular Extensions PHP5 my widget Code: class test extends widget { Code: <div style="border: 1px dotted #ccc; margin-bottom: 10px;"> call widget by Code: <?php widget::run(‘test’); ?> ... i want this Code: <?php
[eluser]Unknown[/eluser]
Thank you wiredesignz for code and support. I have slightly modified the code to each widget has been placed in its directory: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); [quote author="wiredesignz" date="1289633500"]Change the file name to widget_helper.php and relocate the file to application/helpers.[/quote] 1. Create a directory with the name of the widget in the /application/widgets . 2. Place there index.php - widget class file (Class has the same name as the directory) view.php Notice that render() method now get only one argument - $data. It looks like /application/widgets/ my_widget/ index.php view.php
[eluser]Karman de Lange[/eluser]
Thanks very much for this code, works perfect! :cheese: I extended it a bit so I can keep with the MVC theme and keep my data function in own widget model. Simply add following (probably better way, but works for me) Code: function model($model=''){ to use it: Code: $this->model(); //load default model. Just reference model as normal in your code Code: $this->widget_name_model->test(); //calls test() function.
[eluser]boytun[/eluser]
Hello Wiredesignz. Really great job, congratulation ![]() So my question is, how can I use your widget system if I want to apply the HMVC architecture ? . Thanks in advance
[eluser]wiredesignz[/eluser]
Widgets have no specific relation to the HMVC architecture other than supporting the (MVC) View component as partials.
[eluser]boytun[/eluser]
Thanks for your fast reply. I try to make a test ,using widget_helper.php and your example in the first page'User_login'. I fellow the steps, like in the jen's post, but I get this error: input->post('loginform')) { if ($post['username'] == 'admin') { $query = $this->db->query("SELECT uid FROM user WHERE username='admin'"); $result = $query->row(); set_cookie('ci_user', $result->uid, 86500); redirect(); } } if ($visible) $this->render('user_login'); } }application/widgets/User_login/index.php Fatal error: Class 'User_login' not found in C:\xampp\htdocs\application\helpers\widget_helper.php on line 49 but When copy and past the class of the' User_login' in the 'widget_helper', the view is rendred but I get this: input->post('loginform')) { if ($post['username'] == 'admin') { $query = $this->db->query("SELECT uid FROM user WHERE username='admin'"); $result = $query->row(); set_cookie('ci_user', $result->uid, 86500); redirect(); } } if ($visible) $this->render('user_login'); } } A PHP Error was encountered Severity: Warning Message: extract() expects parameter 1 to be array, string given Filename: helpers/widget_helper.php Line Number: 69 I'm working on the Project of the End of Studies and I really need your help I'm waiting for your answer as soon as possible. Thanks
[eluser]galdikas[/eluser]
Hi, Sorry about resurrecting this, but I thought it would be more appropriate than starting new topic. So basically if i use the: Code: $autoload[‘plugin’] = array(‘widget’); I get the fatal error: class widget not found (in my view file). I managed to get it to work by adding this line to the autoload.php file: Code: include(APPPATH."plugins/widget_pi.php"); But even though I am not CI hacker, I have a feeling I should not be doing this (even though it appears to be working). I am using the 3.0-dev version (not sure what the dev means here.. i just donloaded it from CI homepage, this is the value of "CI_VERSION"... So anyway can I leave it the way it is? Or should I fix it? And if latter is true, any ideas how could I make it work in standard way?
[eluser]wiredesignz[/eluser]
Plugins have been deprecated since CI 2.0.0 You could convert the widget plugin into a helper or library as needed. Or you could extend the CI_Loader library with a plugin loader method. Such as follows which is copied from CI1.7.2 but not tested in CI2.1.x or CI3.0 EDIT: Also note that the EXT constant has been deprecated now so you'll need to replace all occurrences of EXT in the widget plugin with '.php' Code: class MY_Loader extends CI_Loader {
[eluser]galdikas[/eluser]
Thanks for your help! I knew that plugins was probably not supported anymore when I needed to create my own directory for it lol I just ended up making it into a helper! Thanks for your help! ![]()
[eluser]Unknown[/eluser]
Hi, a quick question: How can i use jquery or ajax within a view of the widget? I need to update some data which comes from db in a widget view periodicaly, so i have to send a flag in setInterval to the widget controller. e.g. a friendslist-widget how does that work? how do i have tu set the ajax request url? thanks for ur work.. |
Welcome Guest, Not a member yet? Register Sign In |