0
<div class="views-row views-row-1 views-row-odd views-row-first">

  <div class="views-field views-field-name">        
  <span class="field-content"><a href="/committees-groups/test-committee1">Test Committee 1</a></span> 
  </div>  
  <div class="views-field views-field-description"> <div class="field-content"><p>Test Committee one description</p></div>  </div> 

  </div>
  <div class="views-row views-row-2 views-row-even views-row-first">

  <div class="views-field views-field-name">        
  <span class="field-content"><a href="/committees-groups/test-committee2">Test Committee 2</a></span> 
  </div>  
  <div class="views-field views-field-description"> <div class="field-content"><p>Test Committee 2 description</p></div>  </div> 

  </div>

This is the array string i got when i do a print_r($header); in my template.

<?php           
                    $doc = new DOMDocument();
                    $doc->loadHTML($header);
                    $links = array();
                    $arr = $doc->getElementsByTagName("a"); 
                    foreach($arr as $item) { 
                    $href =  $item->getAttribute("href");
                    $text = trim(preg_replace("/[\r\n]+/", " ", $item->nodeValue));
                    $links[$text] = $href;
                    }
                    $serch = $_GET['combine'];
                    $arr = array();
                    $arr =  explode(" ", $serch);
                    foreach($links as $key => $value) { ?>
                    <?php if ( stripos( $value, $arr[0] ) !== false ) {?>
                    <div class="views-row"><a href="<?php echo $value; ?>"><?php echo $key; ?></a></div>
                    <?php } } 
            ?>

This is my code to print the result and search the link title in the array. I need to add the body field (views-field-description) to result display and need to search the keyword ($serch = $_GET['combine'];) inside the body (views-field-description) content.

The title search works fine for me. How can i add it.

0

It is much more easier to implement this using views module. In this tutorial, you can ask user an input, and search on any field in the content type.

  • My requirement is to search the keyword in both taxonomy and nodes at the same time. So i added the taxonomy block above the node block. The node content is searching as expected in both title and body. But the taxonomy is only searching the title. The search functionality should be same for both taxonomy and node content. – drup Mar 18 '15 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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