[SOLVED][Drupal Views] Notice: Undefined property: stdClass::$taxonomy in eval() (line 3 of C:\xampp\htdocs\cxcplus2\sites\all\modules\views\plugins\views

| | 2 min read

A few Drupal users happened to chance on this eror "Notice: Undefined property: stdClass::$taxonomy in eval() (line 3 of C:\xampp\htdocs\cxcplus2\sites\all\modules\views\plugins\
views_plugin_argument_default_php.inc(51) : eval()'d code)" after they had tried to create a block to display related content of a node in Drupal 7 using PHP code. If you are encountering an error of a similar nature in your Drupal website then read on to find the solution.

Here is the fix. Follow the steps below to implement it.

  • Create a Block View
  • Add fields or teasers (Whichever works well)
  • Go to "Contextual filters" (previously Arguments)
  • Add the filter: "Content: Has taxonomy term ID"
  • Configure The filter as follows
    • When the filter value is NOT in the URL: -> Provide default value
    • Type: Taxonomy Term ID from URL
    • Check the box "Load default filter from node page, that's good for related taxonomy blocks."
    • Proceed to select of the taxonomy terms you want here
  • Save the View and display it on the preferred block
  • Since the current View is based on Related Terms proceed with the next step
  • Now we need to add the second filter in order to exclude the current node
  • To do that Click [+] button under Contextual Filters
  • Next select Content: Nid
  • Set 'When the filter value is NOT in the URL' to 'Provide default argument'
  • Next set the 'Default argument type' to 'Content ID from URL'
  • Then proceed to "MORE" and check the "Exclude" box.
  • Remember to embed the block in node pages
  • Finally Save your View

Hope that helps.

The easiest way to solve a Drupal issue is to hand it to the Drupal experts. We can provide a wide range of Drupal services to help you maintain and manage your Drupal websites. Get in touch with us to know more.