11-30-2010, 08:39 PM
[eluser]Devon Lambert[/eluser]
Hello CIers,
I am trying to create a maintenance module that I could direct my site to for times when the site is under construction OR coming soon. The idea I had was to check the site's online/offline status via a setting in the DB (a la PyroCMS) in an extended library called Public_Controller. However, whenever I try to redirect to the Modules controller, my site is getting caught in a redirect loop??
Any ideas would be greatly appreciated.
Here is the code:
The form controller lives under the construction module so I redirect to construction > form. Form's code is below:
I originally had the idea of extending the Public_Controller, but thought this may be what was causing the redirect loop, so I've stuck to extending the main CI_Controller, but to no avail. I know that the Form classes code works because I am able to use it as a controller outside of the module heirarchy; i.e. in the Public_Controller I simply redirect to construction and I create a construction class under the Application's controller folder. So I have to assume that something funky is going on with the modules.
Thanks and thanks again to anyone is can help with this one. :-)
- Devon L.
Hello CIers,
I am trying to create a maintenance module that I could direct my site to for times when the site is under construction OR coming soon. The idea I had was to check the site's online/offline status via a setting in the DB (a la PyroCMS) in an extended library called Public_Controller. However, whenever I try to redirect to the Modules controller, my site is getting caught in a redirect loop??
Any ideas would be greatly appreciated.
Here is the code:
Code:
// Check the frontend hasnt been disabled by an admin
if ( ! $this->settings->frontend_enabled && (empty($this->user) OR $this->user->group != 'admin'))
{
//$error = $this->settings->unavailable_message ? $this->settings->unavailable_message : lang('cms_fatal_error');
// While we test the site, we will display a Coming Soon Module to visitors
redirect('construction/form');
//show_error($error);
}
The form controller lives under the construction module so I redirect to construction > form. Form's code is below:
Code:
class Form extends CI_Controller
{
/**
* Constructor method
*
* @access public
* @return void
*/
public function __construct()
{
// Call the parent's controller
parent::__construct();
$this->load->lang('construction');
$this->load->library('email');
// Set the validation rules
$this->validation_rules = array(
array(
'field' => 'email',
'label' => lang('email_label'),
'rules' => 'required|valid_email'
),
);
// Call validation and set rules
$this->load->library('form_validation');
$this->form_validation->set_rules($this->validation_rules);
// Modify constants below to suit your needs.
$email_to = "[email protected]";
$email_subject = "New e-mail subscriber";
// This is the email message sent to the subscriber
$email_message_to_subscriber = "Thank you for contacting us. We will be in touch with you very soon.";
}
/**
* Handle the form submission
*
* @access public
* @return void
*/
public function index()
{
$this->load->view('form_view');
}
/**
* Handle the form submission
*
* @access public
* @return void
*/
public function submit()
{
#Get POST data
$email = $this->input->post('email') ? $this->input->post('email') : FALSE;
// Set the email message that is sent to the admin.
$message = "Form details below.\n\n";
$message .= "Email: ".$email."\n";
#Set our e-mail fields
$this->email->from($email);
$this->email->to($this->email_to);
$this->email->subject($this->email_subject);
$this->email->message($message);
$this->email->send();
$data['success_message'] = $this->email_message_to_subscriber;
#load our view file
$this->load->view('form_success', $data);
}
} // End Form Class
I originally had the idea of extending the Public_Controller, but thought this may be what was causing the redirect loop, so I've stuck to extending the main CI_Controller, but to no avail. I know that the Form classes code works because I am able to use it as a controller outside of the module heirarchy; i.e. in the Public_Controller I simply redirect to construction and I create a construction class under the Application's controller folder. So I have to assume that something funky is going on with the modules.
Thanks and thanks again to anyone is can help with this one. :-)
- Devon L.