Reply to comment

Alterations to the See Also field

I like how the see also box is working / looking but want more choices when writing something.

I've added a single line text field to allow for the header text which before was hard coded into the tpl file to 'See Also' , and added a full text field to display below the links  within the same div to allow for a short text blurb and perhaps any external links which aren't possible in the node reference field. ( I might add one above or perhaps some sort of flag to choose where the text appears, either above or below the links)

I also added a fieldset to tie all of these elements into the content entry form.

 

custom fields

 

Now in my node-my_type.tpl.php

(Just the main div area)

  <div class="content clear-block">
    <?php
      if ($page != 0){
    $see_also_count = count($node->field_see_also);
    if ($see_also_count>0 && strlen($node->field_see_also[0]['view'])>0){
      if (strlen($node->field_see_also_header[0]['view'])>0){
        print '<div class="seealso"><h3>' . $node->field_see_also_header[0]['view'] . '</h3><ul>';
      }else{
        print '<div class="seealso"><h3>See Also</h3><ul>';
      }
      foreach ($node->field_see_also as $see_also){
        echo '<li>' . $see_also['view'] . '</li>';
      }
      print '</ul>';

      if (strlen($node->field_see_also_footer[0]['view'])>0){
        print $node->field_see_also_footer[0]['view'];
      }
      print '</div>';
    }
      }
    ?>
    <?php print $node->content['body']['#value']; ?>
  </div>

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
1 + 11 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.