Jump to content


Redirection PB

Redirection

  • Please log in to reply
2 replies to this topic

#1 elanouar

elanouar

    Member

  • Members
  • PipPip
  • 27 posts

Posted 18 July 2013 - 05:18 PM

I created a Crud in which i have to send an Email to a group but before sending the email i have to check if the sender has reached the limit number of emails. If the user reached the max number he will be redirected to an information page and if it s not the case the mail will be sent and the user will be redirected to a second page.

Thus as figured below in the code i 'm using the 'callback_before_insert' in which i will try to make my tests and based on the results i will redirect the user to a specific page. Unfortunately the redirect function is dysfunctional.


public function email()
    {    
	 	$this->grocery_crud->set_table('email');					
 
		$this->grocery_crud->columns('source','sujet','contenu','groupe');
		$this->grocery_crud->fields('source','sujet','contenu' ,'groupe');		
		$this->grocery_crud->callback_before_insert(array($this,'checking_and_sending'));		
        $output = $this->grocery_crud->render(); 
        $this->_example_output($output);        
    }	
				 
	
	function checking_and_sending($post_array)
    {  
                .
                .
                .
		if ($h==0)    
		{
			redirect('/Bilelou/index.php/communication/func','location');
		}
			
		else
		{
			
			redirect('/Bilelou/index.php/communication/fun','location');
		}

    
   }


After  verification  I noted that the 'grocery_crud->render()' function overwrite the redirect function and force it to still in the main page.
Is there any solution that could overpass this problem.
Thank you for your help in advance.



#2 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 19 July 2013 - 07:32 AM

Help me here, I am trying to understand your logic.

When do you actually add the newly inserted values as a record to the database?

In all cases it seems that you do a redirect, but if you need the values to be stored you need at least in one case to have a return $post_array;

So in the case that this number hasn't reached the max you allow (via return $post_array) to store the record as normal but you need to have some kind of variable that is enabled (either class or session variable) that is checked on your email function and if this is the case from there redirect.

From the callback redirect, send away only in the case that you don't want the record to be saved in the database.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#3 elanouar

elanouar

    Member

  • Members
  • PipPip
  • 27 posts

Posted 24 July 2013 - 11:06 AM

So in the case that this number hasn't reached the max you allow (via return $post_array) to store the record as normal but you need to have some kind of variable that is enabled (either class or session variable) that is checked on your email function and if this is the case from there redirect.

 

 

Exactly that’s what I would like to establish: I will extract a value from a session and compare it to my actual var. Depending on the comparison result I will save the value and redirect the user to another page; failure or success page.

 

From the callback redirect, send away only in the case that you don't want the record to be saved in the database.

 

 

 

What do you mean exactly by ‘send away’ and how!!

After verification I noted that the, <<render();  line 9 >>, function is overwriting the redirect function that s is situated in the callback . Am I right and how can I overpass this overwriting process !!

Thanks in advance for your help and your time .






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users