WBCE CMS Forum

WBCE CMS – Way Better Content Editing.

You are not logged in.

#1 08.10.2021 18:13:36

losttrip
Member

Only add link attributes if there is a long description

Because I have styles associated with Title text and Preview image links (default and hover effects), even when there is no long description, these link styles are visible on the linked elements (which is confusing to users, and just looks strange).  See image for example:

no link

Is there a way to set up NWI to only place the link properties (a href ) on these elements when there is actually a link necessary?

I was given this working solution to hide the a href when there is no long description or gallery images in NIA:

<div class="mod_nwi_teaserpic">
     {% if (news.CONTENT_LONG or news.HASGALLERYIMAGES) %}
     <a href="{{ news.LINK }}">{% endif %}<img src="{{ news.IMAGE }}" />{% if (news.CONTENT_LONG or news.HASGALLERYIMAGES) %}</a>{% endif %}
</div>
{% endif %}
<div class="mod_nwi_teasertext">
     {% if (news.CONTENT_LONG or news.HASGALLERYIMAGES) %}
     <a href="{{ news.LINK }}">{% endif %}<h3>{{ news.TITLE }}</h3>{% if (news.CONTENT_LONG or news.HASGALLERYIMAGES) %}</a>{% endif %}

Is there a similar solution to achieve this in NWI?

Here is my NWI Post Loop:

<div class="mod_nwi_group">
    <div class="mod_nwi_teaserpic">
        <a href="[LINK]">[IMAGE]</a>
    </div>
    <div class="mod_nwi_teasertext">
       <a href="[LINK]"><h3>[TITLE]</h3></a>
        <div class="mod_nwi_metadata">Published [PUBLISHED_DATE]</div>
            <div class="mod_nwi_shorttext">
                [SHORT]
            </div>
            <span style="visibility:[SHOW_READ_MORE];"><a href="[LINK]">[TEXT_READ_MORE]</a></span>
        </div>
    </div>
    <div class="mod_nwi_spacer"><hr /></div>

Thank you.

Last edited by losttrip (08.10.2021 22:06:42)

Online

#2 09.10.2021 07:54:08

florian
Administrator

Re: Only add link attributes if there is a long description

Good point.
There are only some small changes to the modules/news_img/functions.inc.php needed:

Find 2 times

$anz_post_img = count($images);
            // no "read more" link if no long content
            if ( (strlen($post['content_long']) < 9) && ($anz_post_img < 1)) {
                $post['post_link'] = '#" onclick="javascript:void(0);return false;" style="cursor:no-drop;';
            }

and change it to

$anz_post_img = count($images);
$post_href_link = 'href="'. $post['post_link'].'"';
            // no "read more" link if no long content
            if ( (strlen($post['content_long']) < 9) && ($anz_post_img < 1)) {
                $post['post_link'] = '#" onclick="javascript:void(0);return false;" style="cursor:no-drop;';
		$post_href_link = 'href="'. $post['post_link'].'"';
            }

Find

'LINK'            => $post['post_link'],

and after this, add

'HREF'			  => $post_href_link,

In the page settings, you can use now

<a [HREF]>[IMAGE]</a>

So the <a> tag is generated, but not clickable.

This will be available in the next version of NWI too.

Last edited by florian (09.10.2021 07:55:25)

Offline

Board footer

up