0
Welcome Guest! Login
0 items Join Now

Block Content Particle: Suggestion - Add image link field

    • Chaddo's Avatar
    • Chaddo
    • Sr. Rocketeer
    • Posts: 160
    • Thanks: 2

    Block Content Particle: Suggestion - Add image link field

    Posted 8 years 11 months ago
    • I've been working on customizing particles for my needs, and realized this might be a common request.

      The Block Content particle is a nice generic content particle, but lately I've been adding an Image Link field so that I can quickly add links to images assigned in the Image field.

      Just thought I would suggest that addition of that field/link to the standard Block Content particle as it seems like something that would be generally helpful in most cases.
    • The following users have thanked you: RacerFX

    • Damir's Avatar
    • Damir
    • Preeminent Rocketeer
    • Posts: 22450
    • Thanks: 2679
    • Web Developer

    Re: Block Content Particle: Suggestion - Add image link field

    Posted 8 years 11 months ago
    • RacerFX's Avatar
    • RacerFX
    • Sr. Rocketeer
    • Posts: 175
    • Thanks: 13

    Re: Block Content Particle: Suggestion - Add image link field

    Posted 8 years 11 months ago
    • Thought I would add my solution for someone who wants to add a link to the subcontent image.

      Created folder TEMPLATE_DIR/custom/particles
      Copied both blockcontent.html.twig and blockcontent.yaml from the TEMPLATE_DIR/particles directory

      Added the following to the blockcontent.yaml custom file right below subcontent .img lines. Note: no tabs in text.
              .link:
                type: input.text
                label: Image Link
      
              .linktarget:
                type: select.selectize
                label: Target
                description: Target browser window when item is clicked.
                placeholder: 'Select...'
                default: _self
                options:
                    _self: Self
                    _blank: New Window

      Replaced the following to the blockcontent.html.twig custom file.
                  {% if subcontent.img %}<img src="{{ url(subcontent.img) }}" class="g-blockcontent-subcontent-img" alt="{{ subcontent.title|e }}" />{% endif %}
      With
                  {% if subcontent.link %}<a target="{{ subcontent.linktarget|default('_self')|e }}" href="{{ subcontent.link|e }}">{% endif %}
                  {% if subcontent.img %}<img src="{{ url(subcontent.img) }}" class="g-blockcontent-subcontent-img" alt="{{ subcontent.title|e }}" />{% endif %}
                  {% if subcontent.link %}</a>{% endif %}

      I'm not sure how this may affect the use of RokBox Image, in this subcontent since it too has a href. But I wanted to link logos and other images using this block content thus adding the target window to the link. Works perfectly.
    • Last Edit: 8 years 11 months ago by RacerFX.

Time to create page: 0.071 seconds