How to get the field data

Hi i’m using entityreference, i hava an content type"test" that contain a field that refer to categorie and this categorie contain a field_theme also referenced to another content type theme_test. On Theme_test i have a field entityreference that refer to Criter and this last is saved on Test Finally on an other field let’s name it recap.

array(19) {
  ["#theme"]=>
  string(5) "field"
  ["#weight"]=>
  string(1) "6"
  ["#title"]=>
  string(18) "suivi pédagogique"
  ["#access"]=>
  bool(true)
  ["#label_display"]=>
  string(5) "above"
  ["#view_mode"]=>
  string(4) "full"
  ["#language"]=>
  string(3) "und"
  ["#field_name"]=>
  string(11) "field_suivi"
  ["#field_type"]=>
  string(15) "entityreference"
  ["#field_translatable"]=>
  string(1) "0"
  ["#entity_type"]=>
  string(4) "node"
  ["#bundle"]=>
  string(4) "test"
  ["#object"]=>
  object(stdClass)#80 (35) {
    ["vid"]=>
    string(3) "500"
    ["uid"]=>
    string(1) "0"
    ["title"]=>
    string(25) "test1_2021-08-20 16:02:29"
    ["log"]=>
    string(0) ""
    ["status"]=>
    string(1) "1"
    ["comment"]=>
    string(1) "1"
    ["promote"]=>
    string(1) "0"
    ["sticky"]=>
    string(1) "0"
    ["nid"]=>
    string(8) "10485403"
    ["type"]=>
    string(4) "test"
    ["language"]=>
    string(3) "und"
    ["created"]=>
    string(10) "1629468149"
    ["changed"]=>
    string(10) "1629468149"
    ["tnid"]=>
    string(1) "0"
    ["translate"]=>
    string(1) "0"
    ["revision_timestamp"]=>
    string(10) "1629468149"
    ["revision_uid"]=>
    string(1) "1"
    ["field_id_externe"]=>
    array(0) {
    }
    ["field_categories"]=>
    array(1) {
      ["und"]=>
      array(1) {
        [0]=>
        array(3) {
          ["target_id"]=>
          string(2) "20"
          ["entity"]=>
          object(stdClass)#96 (30) {
            ["vid"]=>
            string(2) "20"
            ["uid"]=>
            string(1) "1"
            ["title"]=>
            string(7) "r489_1A"
            ["log"]=>
            string(0) ""
            ["status"]=>
            string(1) "1"
            ["comment"]=>
            string(1) "1"
            ["promote"]=>
            string(1) "0"
            ["sticky"]=>
            string(1) "0"
            ["nid"]=>
            string(2) "20"
            ["type"]=>
            string(9) "categorie"
            ["language"]=>
            string(3) "und"
            ["created"]=>
            string(10) "1625752758"
            ["changed"]=>
            string(10) "1629454614"
            ["tnid"]=>
            string(1) "0"
            ["translate"]=>
            string(1) "0"
            ["revision_timestamp"]=>
            string(10) "1629454614"
            ["revision_uid"]=>
            string(1) "1"
            ["field_famille"]=>
            array(0) {
            }
            ["field_ut"]=>
            array(0) {
            }
            ["field_id_externe"]=>
            array(1) {
              ["und"]=>
              array(1) {
                [0]=>
                array(3) {
                  ["value"]=>
                  string(7) "r489-1A"
                  ["format"]=>
                  NULL
                  ["safe_value"]=>
                  string(7) "r489-1A"
                }
              }
            }
            ["field_theme"]=>
            array(1) {
              ["und"]=>
              array(2) {
                [0]=>
                array(1) {
                  ["target_id"]=>
                  string(8) "10485206"
                }
                [1]=>
                array(1) {
                  ["target_id"]=>
                  string(8) "10485236"
                }
              }
            }

I want to display Criter by theme on node "test" programmatically but idon’t know how, i google it but no one have some idea for Three level of referenced entity.

Thanks to All 🙂

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

How to get the field data

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.