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: 
 array(1) {
array(1) {
  array(13) {
    string(1) "1"
    string(1) "1"
    string(37) "Golden_tabby_and_white_kitten_n01.jpg"
    string(46) "public://Golden_tabby_and_white_kitten_n01.jpg"
    string(10) "image/jpeg"
    string(5) "20388"
    string(1) "1"
    string(10) "1426087127"
    array(0) {
    string(0) ""
    string(0) ""
    string(3) "737"
    string(3) "300"


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

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.