Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-05-26 17:47:24

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,262
Website GitHub Mastodon Twitter

noscript option

hi all,

A quick question which might be easy to answer but I just can’t get my head around it.

I started using a jquery script for image rotation. Apart for the js in the head all I need to add is

<txp:images category="random" limit="5" sort="rand()" wraptag="ul" break="li" class="rslides">
<a href="/<txp:image_info type="name" />"><txp:image /></a>
</txp:images>

The problem is that when the browser javascript is off the whole layout breaks. Is there a method with which I can achieve something like:

<noscript>
<txp:images category="random" limit="1" sort="rand()" wraptag="ul" break="li" class="rslides">
<txp:else />
<txp:images category="random" limit="5" sort="rand()" wraptag="ul" break="li" class="rslides">
</noscript>
<a href="/<txp:image_info type="name" />"><txp:image /></a>
</txp:images>

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#2 2013-05-26 20:29:50

etc
Developer
Registered: 2010-11-11
Posts: 5,472
Website GitHub

Re: noscript option

Hi Yiannis,

that’s hardly possible without recurring to AJAX. The simplest solution is probably CSS:

<noscript><style>
ul.rslides li {display:none}
ul.rslides li:first-child {display:inherit}
</style></noscript>

Offline

#3 2013-05-27 05:07:15

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,262
Website GitHub Mastodon Twitter

Re: noscript option

Hi Oleg,

Thanks!!! Your suggestion works beautifully.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#4 2013-05-27 06:16:43

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,262
Website GitHub Mastodon Twitter

Re: noscript option

Checking on it again, it does not validate. :(


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#5 2013-05-27 07:12:13

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,262
Website GitHub Mastodon Twitter

Re: noscript option

Ok this is how I solved it

I gave a class="no-js" to the body
From there on jquery comes to the rescue

<script type="text/javascript">
$(document).ready(function() {
$('body').removeClass('no-js').addClass('js');
});
</script>

The script replaces the class from no-js to js

I changed the styles to

.no-js ul.rslides li {display:none}
.no-js ul.rslides li:first-child {display:inherit}

simple:)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB