English 中文(简体)
• 如何在连续8年获得实地格式?
原标题:How to get format settings of field in drupal 8?

我有一个连续8个项目,我的客户要求我从内容类型上获得实地格式,以回应一个移动设备复印机。 我创建了一个新的单元,并试图获取格式环境数据。 但却没有成功。 我只是找到一个领域,但并不是在内容类型上展示实地环境。

On picture below, I want get all data of format column, and show it as a json. Please help me. Thanks so much! enter image description here

问题回答

如果你想为某个具体领域提取格式环境,你可以采用这一选择:

/** @var DrupalCoreEntityEntityDisplayRepository $entityDisplayRepository */
$entityDisplayRepository = Drupal::service( entity_display.repository );
$productViewDisplay = $entityDisplayRepository->getViewDisplay( node ,  page ,  teaser  /* optional */);
$all_formatters_settings = $productViewDisplay->get( content );

$formatter_settings = $all_formatters_settings[ field_my_field ];

如果你需要找到植被,你也可以在储存库中以“条码”代替“条码”代替“条码”。

/** @var DrupalCoreEntityEntityDisplayRepository $entityDisplayRepository */
$entityDisplayRepository = Drupal::service( entity_display.repository );
$productViewDisplay = $entityDisplayRepository->getFormDisplay( node ,  page ,  teaser  /* optional */);
$all_formatters_settings = $productViewDisplay->get( content );

$formatter_settings = $all_formatters_settings[ field_my_field ];

There is another way to get the formatter settings.

$formatter_settings = Drupal::entityTypeManager()
  ->getStorage( entity_view_display )
  ->load("entity_type_id.entity_bundle.view_mode")
  ->getRenderer( field_logo_kataloga )
  ->getSettings();




相关问题
Problem with protected fields in base class in c++

I have a base class, say BassClass, with some fields, which I made them protected, and some pure virtual functions. Then the derived class, say DerivedClass, like class DerivedClass : public BassClass....

SharePoint send an email to users specified in a Field

I have a SharePoint list of Issues and have set a column (called Alert) to a “Person or Group” (allowing multiple names). I would like the system to send an email to all the users listed in the ...

Why do I have to do ldarg.0 before calling a field in MSIL?

I want to call a function, with as parameters a string and an Int32. The string is just a literal, the Int32 should be a field. So I thought it should be something like: .method public hidebysig ...

Update Array field in progress DB using ODBC

I access the progress DB using ODBC in my C# program, and I need to update some fields,which are array data type. so how can I write my sql statement to do such things? I read some progress ...

How can I pass a User model into a form field (django)?

Basically, I need to use the User s password hash to encrypt some data via a custom model field. Check out the snippet I used here: Django Encryption. I tried this: class MyClass(models.Model): ...

Silverlight 3 Dataform - how to add fieds at runtime

I am creating a DataForm from dynamic data (so I can t create the columns in the xaml), I currently create columns for my DataGrid (I have not worked out how I can create a button + event in a colomn ...

热门标签