0

I have a custom filter added for a content type 'sample'. On selecting the custom filter for the node body, it checks for webform tokens like [webform:1234], by exploding it checks whether it is a webform or not. If it is a webform, it loads that node and render the same to the node body. Here is my code please have a check.

function landing_page_filter($text, $filter, $format, $langcode, $cache, $cache_id) {
  preg_match_all('/\\[([a-zA-z0-9_]+:[a-zA-z0-9_]+)+\\]/m', $text, $match);
  $matches = $match[0];
  foreach ($matches as $token) { dpm($token);
    $token_name = str_replace(array( '[', ']' ), '', $token);
    $type = explode(':', $token_name);
    if ($type[0] == 'webform') {
      $nid = $type[1]; 
      $node = node_load($nid);
     $form = drupal_render($node);
    }
  }
  return $form;
}
2
  • So what is the problem? Commented Jul 15, 2015 at 10:54
  • @AlirezaTabatabaeian The form is not getting replaced... Commented Jul 16, 2015 at 5:09

1 Answer 1

0

Rather than loading a page based on nid and then returning the loaded output as an HTML , use drupal_goto function like below :

drupal_goto('node'/.$nid);
1
  • I have a node suppose node/123 in which there are few contents, I would like to render another node suppose 234 to 123. I'm trying to do this. Hope you understood. Commented Jul 16, 2015 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.