[eluser]slowgary[/eluser]
I see breaddes. There are several options. Buso is right, you can use Javascript to interact with the server, then you won't even have to change pages in your widgets. If you're not experienced with Javascript, using a library like jQuery might make things easier.
If the Javascript route seems too daunting, you can make your widget links all point to the current page and just pass some data along with the HTTP request. Since CodeIgniter prefers that we don't use GET data, you'd want to make your widgets use forms instead of links.
So if you were creating a voting widget, there would be a few parts...
The Initial View
Code:
<div class='right_column'>
What is your favorite color?
<form action="<?php echo $_SERVER['PHP_SELF']?>">
<div>
<label>
<input type='radio' name='widget_vote_color' value='red'/> Red
</label>
<label>
<input type='radio' name='widget_vote_color' value='green'/> Green
</label>
<label>
<input type='radio' name='widget_vote_color' value='blue'/> Blue
</label>
<label>
<input type='submit' value='Vote'/>
</label>
</div>
</form>
</div>
The "already voted view"
Code:
<div class='right_column'>
<strong>Thank you for voting!</strong>
</div>
And the voting widget library
Code:
// pseudocode
class VotingWidget extends Controller
{
function view()
{
if(isset($_COOKIE['somecookie']) AND $_COOKIE['somecookie'] == 'already_voted') {
$this->load->view('voting_widget_already_voted');
} else if($vote = $this->input->post('widget_vote_color')) {
//store the vote in the database and set $_COOKIE['somecookie'] = 'already_voted';
$this->load->view('voting_widget_already_voted');
} else {
$this->load->view('voting_widget_initial_view');
}
}
}
None of this code has been tested, and I'm not even sure if you can extend the Controller class in a library, but it should hopefully serve as an illustration of how to accomplish something like this. Personally, I would take the Javascript route as it will provide a better user experience, less server load, and less page loads for the user.
I hope this helps.