0

Have not touched Drupal for 3 years already and try to remember how to do the templates.

Banner node -- I checked the field name: field_data_field_banner and wanted to print every node banner image up to 4.

According to dump: 
 ["field_banner"]=>
 array(1) {
["und"]=>
array(1) {
  [0]=>
  array(13) {
    ["fid"]=>
    string(1) "1"
    ["uid"]=>
    string(1) "1"
    ["filename"]=>
    string(37) "Golden_tabby_and_white_kitten_n01.jpg"
    ["uri"]=>
    string(46) "public://Golden_tabby_and_white_kitten_n01.jpg"
    ["filemime"]=>
    string(10) "image/jpeg"
    ["filesize"]=>
    string(5) "20388"
    ["status"]=>
    string(1) "1"
    ["timestamp"]=>
    string(10) "1426087127"
    ["rdf_mapping"]=>
    array(0) {
    }
    ["alt"]=>
    string(0) ""
    ["title"]=>
    string(0) ""
    ["width"]=>
    string(3) "737"
    ["height"]=>
    string(3) "300"
  }
}

}

<ul>
  <?php if($node -> field_banner < 4){?>
  <li><?php print $node -> field_banner['und'][0]['uri'];?>
  </li>
  <?php }?>
<ul>

It gave error: Notice: Undefined variable: node

Tried a few ways but I couldn't get the image appear in slide :(

Help appreciated. Thanks

  • Where are you putting this code? – Patrick Ryan Mar 11 '15 at 16:14
  • Are you doing it in $node--banner.tpl.php? PS: don't use ['und'] but [LANGUAGE_NONE] – GwenM Mar 11 '15 at 17:00
  • @PatrickRyan - banner in page.tpl.php. – joe Mar 12 '15 at 1:44
  • @Namari - no it is in page.tpl.php so it can show slider on front page. i try [language_none] but still get same error – joe Mar 12 '15 at 1:45
  • if it's front page why don't you use page--front.tpl.php ? have you try to put echo 'test'; to see if it works? It might be coming from the location of this file in the wrong theme, subtheme... – GwenM Mar 12 '15 at 9:29

Your Answer

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

Browse other questions tagged or ask your own question.