- Issue created by @dkyndt
Hi @dkyndt, your are right, currently there is no preset in module to achieve that, anyway there are some options to have it quite easily thanks to all included tools & versatility of vlsuite like:
Create "CTA Image" block with two fields; one for media image or icon (field_image) & other for link (field_link)*, configure block display without enabling layout builder & exposing those two fields &:/**
* Implements hook_entity_view_alter().
*/
function MYMODULE_content_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
if ($entity->getEntityTypeId() === 'block_content' && $entity->bundle() === 'cta_image' &&
!empty($build['field_link']) && !empty($build['field_image'])) {
foreach (Element::children($build['field_link']) as $delta) {
$title = $build['field_link'][$delta]['#title'];
$build['field_link'][$delta]['#title'] = !empty($build['field_image'][$delta]) ? $build['field_image'][$delta] : $title;
}
$build['field_image']['#access'] = FALSE;
}
}
*NOTE: You can also do it just for specific display &/or use provided bundle fields or prepare a SDC component or using any other custom/contrib approach. Hope it helps.Maybe that will be included into VLSuite preset, let's see.
Hi @CRZDEV
I created the block as suggested, however, I don't know where to put the code.
I tried in the vlsuite_block.module, but this seems not to work.
I do not see the CTA Image in the VLsuite layout builder.Thanks already.
Drupal may be quite complex at start, there are multiple concepts that is needed to extend vlsuite / layout builder, like entities, content blocks, fields, manage display, form display, widgets, formatters, layout builder restrictions along many others. Maybe best option is change this issue category to "Feature request" & include this as part of inittial shuttle.
That means this issue new target is to include that component by default, so you need to wait until it is solved & new release is published.- Merge request !43Issue #3419325: Image block & icon block: linked image or icon with new optional cta field → (Merged) created by CRZDEV
- last update
9 months ago 3 pass - Status changed to Needs review
9 months ago 12:33pm 1 April 2024 Included new MR with changes to allow link Image block and/or icon block. Ready to check.
Note @dkyndt: to use apply patch with changes from MR in your composer project: "https://git.drupalcode.org/project/vlsuite/-/merge_requests/43.patch" or download and use downloaded file "wget https://git.drupalcode.org/project/vlsuite/-/merge_requests/43.patch -O 3419325-vlsuite-clickable-image-MR-43-1.patch", it should look like something like this:
"drupal/vlsuite": { "Clickable image - https://drupal.org/i/3419325": "patches/3419325-vlsuite-clickable-image-MR-43-1.patch" },
After applying patch, run pending database updates & new field should appear for "Icon (VLSuite)" and "Image (VLSuite)": "Linked to (optional)".
- Assigned to Alejandro Cabarcos
- Status changed to RTBC
9 months ago 10:24am 2 April 2024 - last update
8 months ago 3 pass - Status changed to Fixed
8 months ago 4:50pm 16 April 2024 Automatically closed - issue fixed for 2 weeks with no activity.