WBCE CMS – Way Better Content Editing.
You are not logged in.
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:
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 21:06:42)
Offline
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 06:55:25)
Sorgen sind wie Nudeln: man macht sich meist zu viele.
Offline
Sorry it has taken me so long to test this out.
I installed NWI version 5.0.13 which from my understanding has this functionality included.
I changed my code for the preview image to:
<a [HREF]>[IMAGE]</a>
The results on the front end are that the image css hover effects still trigger, because there is still the <a> tag attributed to the image. The only noticeable change from the old version is that instead of the red "no drop" cursor on hover, the cursor on hover of the image is the "pointer":
I'm sorry to report, this does not accomplish what I was looking for:
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?
If there is no details or gallery, I do not want there to be <a> tags on the title or preview image. Therefor there will be no confusing hover effects on these elements.
As I said, the following NIA code accomplishes this result:
{% 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 %}
Is there a way to accomplish this with NWI?
---
Also, I though I should point out that although the install succeeded:
... the Add-Ons module details still show 5.0.7:
Offline
Sorry for my wordy posts. I'll try to simplify my question.
Is there a way to only add the <a> (href) tag IF the post has content.long or gallery images?
Something like this:
<div class="mod_nwi_teaserpic">
<if (news.CONTENT_LONG or news.HASGALLERYIMAGES)><a href="[LINK]"><end if>[IMAGE]<if (news.CONTENT_LONG or news.HASGALLERYIMAGES)></a><end if>
</div>
<div class="mod_nwi_teasertext">
<if (news.CONTENT_LONG or news.HASGALLERYIMAGES)> <a href="[LINK]"><end if><h3>[TITLE]</h3><if (news.CONTENT_LONG or news.HASGALLERYIMAGES)></a><end if>
</div>
Like I said, the code below accomplishes this in NIA.
{% 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 %}
But I need the same functionality in NWI.
Offline
Please find attached the NWI version 5.0.14 for testing.
I've added two new placeholders, [AOPEN] and [ACLOSE].
Update NWI as usual*. Then, in the post loop settings, replace
<a href="[LINK]"><h3>[TITLE]</h3></a>
and
<a href="[LINK]">[IMAGE]</a>
with
[AOPEN]<h3>[TITLE]</h3>[ACLOSE]
and
[AOPEN][IMAGE][ACLOSE]
The complete <a href="foo.php"> and the closing </a> will that way be generated only if there is a long text and/or gallery to that post.
* idk why, but the version shown in the backend is only increased if Add-Ons > Advanced > Reload modules is executed.
Last edited by florian (08.02.2022 11:29:49)
Sorgen sind wie Nudeln: man macht sich meist zu viele.
Offline
losttrip, berny
Florian. Your new version with the added functionality works beautifully. Thank you so much.
Demo - The top post has long text, the bottom post does not have long text or a gallery.
I do not mean to sound negative or appear to be questioning anyone's logic, I am just curious why this resulting behaviour would not be the preferred default? Specifically, I am curious what the point is of keeping the <a> href tag present when there is no link (long text or gallery) to go to? ... when doing so further forces the use of javascript to change the cursor appearance on hover?
Please don't feel the need to explain, I am just puzzling out loud.
I'm very grateful for everything you do for those of us who benefit from the joys of using WBCE. And, on a personal level, above your generous efforts, your kindness and patience are deeply appreciated.
Offline