Goal :
I have a view which displays multiple nodes in full view including the comments. I want to redirect the users who comment using my view back to the view and not to the article.
At the same time if the user comments on the node and does NOT use MY VIEW they should not be redirected. In other words the redirect to be used only on my view.
My below code works well but unfortunately all the the sites comments form start to redirect. I only want to redirect users who are using my panel view on the path /newvc to get redirected.
My code:
function customchatter_form_comment_form_alter(&$form, &$form_state, $form_id){
$form['#submit'][] = 'submitForm';
}
function submitForm($form, &$form_state) {
$form_state['redirect'] = 'newvc'; // need to redirect
}
My logical problem:
I can't seem to get the logic which will allow me to isolate comments coming from my view.
I tried to use the below code but it did not work as all the comments even the ones in my view follow the same path logic.
$url_components = explode('/', request_uri());
if ($url_components[1]=='comment' && $url_components[2]=='reply') {
// no use as this still targets all the comments.
}
I solved it by using the below code. $_POST['submissionpath'] holds the path to the original page.
function submitForm($form, &$form_state) {
print $form;
$form_state['redirect'] =$_POST['submissionpath'];
}