Code Monkey home page Code Monkey logo

Comments (5)

samhibberd avatar samhibberd commented on June 1, 2024

Would it be ok to take a look at your template code?

from linkit.

kragit avatar kragit commented on June 1, 2024

LinkIt version 0.6 on Craft 2.1.2564. LinkIt is part of an entry Matrix block (multiple types of blocks). Throws error. Using this exact setup (LinkIt as part of an entry matrix block amongst other block types) with version 0.5 on Craft 2.0.2540 does work.

{% for block in blocks %}
    {% switch block.type %}
        {% case "singleImageBlock" %}
            {% set oneImage = block.image.first() %}
            {% set pixelWidth = (960 * (block.width/100))|round(0,'ceil') %}
            {% set thumb = {mode: 'fit', width: pixelWidth, quality: 75} %}
            <div class="singleImage {{block.alignment}}" style="width: {{block.width}}%">
                {% if block.optionalLink is defined %}
                    <a href="{{block.optionalLink.url}}" {{ block.optionalLink.target ? ' target="_blank"' }}><img src="{{ oneImage.url(thumb) }}" width="100%"/></a>
                {% else %}
                    <img src="{{ oneImage.url(thumb) }}" width="100%"/>
                {% endif %}
            </div>
    {% endswitch %}
{% endfor %}

LinkIt version 0.5 on Craft 2.0.2540. LinkIt is part of a matrix block (where a link block is the only option) inside a global set. Works fine. Using this exact setup (matrix inside global) with version 0.6 on Craft 2.1.2564 does work.

<nav id="headerNav">
    <ul>
        {% for link in navigation.links %}
        <li><a href="{{ link.href.url }}" {{ link.href.target ? ' target="_blank"' }} {{link.href.url in craft.request.url and link.href.url != siteUrl ? 'class="active"' }} title="{{ link.href.linkText }}">{{ link.href.linkText }}</a></li>
        {% endfor %}
    </ul>
</nav>

LinkIt version 0.5 on Craft 2.0.2540. LinkIt is a regular entry field (not in a matrix block). Works fine.

{% switch entry.type %}
    {% case "blogLink" %}
        {% set blogLinkText = '"'~entry.blogFeatLink.url~'" class="blogExtLink" target="_blank"' %}
    {% endswitch %}
        <div class="blogPostMedSidebar">
            by {{entry.author.fullName}}<br />
            {{entry.postDate.format("F j, Y")}}
        </div>
        {% set blogNoLink = '"'~entry.url~'"' %}
        <div class="col-sm-22">
            <h1><a href={{ blogLinkText is defined ? blogLinkText|raw : blogNoLink|raw }}>{{entry.title}}</a></h1>
        </div>

from linkit.

samhibberd avatar samhibberd commented on June 1, 2024

Can you try switching out this line:

{% if block.optionalLink is defined %}

With:

{% if block.optionalLink is defined and block.optionalLink %}

block.optionalLink will always be defined, but may not always be set (therefore returning a null variable)

I suspect this is the cause of the issues.

Let me know?

from linkit.

kragit avatar kragit commented on June 1, 2024

That does indeed work (sorry for it being such a simple issue!).

from linkit.

samhibberd avatar samhibberd commented on June 1, 2024

Not to worry, we've all been there, doesn't matter how long you look at it you just cant spot the simple ones.

Just shout if you have any other issues!

from linkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.