function social_post_update_8804 in Open Social 10.1.x
Same name and namespace in other branches
- 10.3.x modules/social_features/social_post/social_post.install \social_post_update_8804()
- 10.0.x modules/social_features/social_post/social_post.install \social_post_update_8804()
- 10.2.x modules/social_features/social_post/social_post.install \social_post_update_8804()
Create "Featured" view mode/display for post.
File
- modules/
social_features/ social_post/ social_post.install, line 155 - Install, update and uninstall functions for the social_post module.
Code
function social_post_update_8804() {
// Create a new post featured entity view mode.
if (!EntityViewMode::load('post.featured')) {
EntityViewMode::create([
'targetEntityType' => 'post',
'id' => 'post.featured',
'status' => TRUE,
'label' => t('Featured'),
])
->save();
}
// Create view display for post bundle of Post entity.
if (!EntityViewDisplay::load('post.post.featured')) {
$display = EntityViewDisplay::load('post.post.default')
->toArray();
unset($display['content']['field_post_comments'], $display['hidden']['like_and_dislike']);
$display['content']['like_and_dislike'] = [
'weight' => 3,
'region' => 'content',
];
$display = array_merge($display, [
'uuid' => NULL,
'_core' => NULL,
'targetEntityType' => 'post',
'mode' => 'featured',
]);
EntityViewDisplay::create($display)
->save();
}
}