[eluser]cideveloper[/eluser]
[quote author="vincej" date="1337031559"]I think cideveloper prorbaly has it right. My controller makes a second server call:
Code:
$data['customerfullname'] = $this->MCustomer->customerfullname($customerid);
However I could not make my flashdata work so in the end I took the 'lazy' way out and simply put this in my view:
Code:
if (empty($completesale)){
echo "<p class='message'> No Accounts Waiting Payment</p>";
}
[/quote]
I think everyone has taken what I said in the wrong way. The reason it is not working is that flash data is used to persist data to another page on redirect, then kill that data. Your "lazy" method is actually correct in that you are not redirecting to another page so you dont actually need flash data. Your "second server call" has nothing to do with it. take for example the below.
Controller
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class FD extends CI_Controller {
function __construct(){
//Contructor function
parent::__construct();
//$this->output->enable_profiler(TRUE);
}
function index() {
$data['payment_id'] = $this->completesale();
if($data['payment_id']) {
$this->load->vars($data);
$this->load->view('test/test1');
} else {
redirect('fd/secondpage');
}
}
function secondpage() {
$data = array (
'payment_id' => ''
);
$this->load->vars($data);
$this->load->view('test/test1');
}
function completesale() {
$db_result = false;
if($db_result) {
return $db_result;
} else {
$this->session->set_flashdata('payment_error','No Orders Waiting Payment');
return false;
}
}
}
View
Code:
<?php
echo 'Hello World<br />' . chr(10);
if ($this->session->flashdata('payment_error')){
echo "<p class='message'>". $this->session->flashdata('payment_error')."</p>";
} else {
echo $payment_id . '<br />' . chr(10);
}
?>
Not the best example but proves the point. When I said second call I meant redirect.