Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#37 2009-04-02 16:47:04

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,943
Website GitHub

Re: Using jquery for fading in and out articles (like a flash banner)

Glad it’s working now. I’d never have spotted that if it hadn’t been for you guys keeping me on my toes: thanks!

decoderltd wrote:

Interesting to hear that javascripts can go anywhere in a document

Well the jury’s still out a bit. Purists argue (probably rightly) that JS should actually always be a separate file for lots of good reasons.

But a hunk of js can occur anywhere you like, and with jQuery the distinction between where is ‘best’ for inline JS is blurred due to the fact you tend to tell jQuery to execute code when the DOM is ready (which is usually before the page is actually rendered as you see it). Thus it’s not that important where your code actually resides since the browser has to ‘get to the end’ of the page first to prepare the DOM.

At least that’s my understanding; it may be wrong, but I’ve not noticed any ill effects, aside from some occasionally idiotic IE6 behaviour with embedded (Flash) content.

as I have a dedicated full width div for the images is there a way of have them separate to the article?

Not quite sure I follow. You can put your smd_gallery tag anywhere you like. But of course if you want to use the article_image to hold the image IDs then you cannot put the smd_gallery tag anywhere ‘outside’ a <txp:article /> or <txp:article_custom /> tag.

If you have a fixed list of images you want to put at the top of, say, an article list page then you can certainly put an smd_gallery tag directly in a Page template. Either hard-code the IDs in the tag itself or store them in a variable. e.g. <txp:variable name="image_ids" value="24,18,37,4,19" /> and then <txp:smd_gallery id="?image_ids" ... />. Or use an image category to hold your pictures instead.

Last edited by Bloke (2009-04-02 16:49:30)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#38 2009-04-02 16:51:49

decoderltd
Member
From: London
Registered: 2006-06-20
Posts: 248
Website

Re: Using jquery for fading in and out articles (like a flash banner)

Thanks for the clarification Stef, I was indeed trying to put the image outside the <txp:article /> tag – will need to work on my layout!

Offline

#39 2009-10-12 13:36:58

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

Re: Using jquery for fading in and out articles (like a flash banner)

decided to try jquery in my testpage head . uploaded both js files, wrote

this between <head> tags

<script type="text/javascript" src="/textpattern/javascripts/jquery-1.3.2.js"></script>
<script type="text/javascript" src="/textpattern/javascripts/jquery.cycle.lite.js"></script>
<script type="text/javascript">
$(function() { $('#head').cycle({ delay: 2000, speed: 500 });
</script>

and this to <body>

	<div id="head">
<txp:image id="57" /><txp:image id="56" /><txp:image id="55" />
	</div>

but it won’t work. could anybody tell me what’s wrong here?

Offline

#40 2009-10-12 14:33:46

decoderltd
Member
From: London
Registered: 2006-06-20
Posts: 248
Website

Re: Using jquery for fading in and out articles (like a flash banner)

Hi Gallex,

You could do something like this:

Create an image category called ‘header-images’ (or any other name) and assign this to the images you want to use, then add this:

<div id="head">
   <txp:smd_gallery wraptag="div" html_id="fade" class="pics" category="header-images" sublevel="all" sort="random" />
</div><!--ends #head-->

This code searches through any sub-categories and displays them in a random order. Of course, you’ll also need to install Stef’s fantastic little gallery plug-in (and don’t forget smd_lib while you’re there).

Hope that helps.

Last edited by decoderltd (2009-10-12 15:04:00)

Offline

#41 2009-10-12 15:01:39

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: Using jquery for fading in and out articles (like a flash banner)

I’m no jQuery specialist, I just count. In $(function() { $('#head').cycle({ delay: 2000, speed: 500 }); you open 1 more curly bracket and 1 more parenthesis than you close.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#42 2009-10-13 10:03:52

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

Re: Using jquery for fading in and out articles (like a flash banner)

uli wrote:

I’m no jQuery specialist, I just count. In $(function() { $('#head').cycle({ delay: 2000, speed: 500 }); you open 1 more curly bracket and 1 more parenthesis than you close.

re-downloaded and re-uploaded js files, checked the file paths in total validator, played with different javascript code. below the solution i copied from here . still nothing…don’t get it…

<script type="text/javascript" src="http://www.muinasjutupidu.ee/textpattern/file_download/9/jquery-1.3.2.js"></script>
<script type="text/javascript" src="http://www.muinasjutupidu.ee/textpattern/file_download/8/jquery.cycle.lite.js"></script>
<script type="text/javascript">$(document).ready(function() {
    $('#head').cycle({ fx: 'fade', speed: 2500	});
});

decoderltd, but i see no reasons why it should not work with just 3 images – without gallery plugin, do you? like in this sample solution

Offline

#43 2009-10-13 10:10:26

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

Re: Using jquery for fading in and out articles (like a flash banner)

Gallex wrote:

<script type="text/javascript" src="http://www.muinasjutupidu.ee/textpattern/file_download/9/jquery-1.3.2.js"></script>
<script type="text/javascript" src="http://www.muinasjutupidu.ee/textpattern/file_download/8/jquery.cycle.lite.js"></script>
<script type="text/javascript">$(document).ready(function() {
    $('#head').cycle({ fx: 'fade', speed: 2500	});
});

Try

<script type="text/javascript" src="<txp:site_url />files/jquery-1.3.2.js"></script>
<script type="text/javascript" src="<txp:site_url />files/jquery.cycle.lite.js"></script>
<script type="text/javascript">$(document).ready(function() {
    $('#head').cycle({ fx: 'fade', speed: 2500	});
});

Last edited by colak (2009-10-13 10:31:13)


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

Offline

#44 2009-10-13 10:37:39

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: Using jquery for fading in and out articles (like a flash banner)

Gallex, your paths are clickable in FF’s source code, so they should be correct.

Edit: Deleted overhasty crap.

Last edited by uli (2009-10-13 10:45:19)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#45 2009-10-13 10:56:58

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

Re: Using jquery for fading in and out articles (like a flash banner)

colak wrote:

Try

<script type="text/javascript" src="<txp:site_url />files/jquery-1.3.2.js"></script>
<script type="text/javascript" src="<txp:site_url />files/jquery.cycle.lite.js"></script>
<script type="text/javascript">$(document).ready(function() {
    $('#head').cycle({ fx: 'fade', speed: 2500	});
});

nope…

Offline

#46 2009-10-13 11:21:44

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

Re: Using jquery for fading in and out articles (like a flash banner)

tried with jquery-1.3.1.js and jquery-1.3.2.mini.js libraries and jquery.cycle.all.js plugin but nothing…

so, paths are correct, plugin and library files are correct, transition code is correct, images paths are correct – what left…? ;)

Offline

#47 2009-10-13 11:25:53

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: Using jquery for fading in and out articles (like a flash banner)

Gallex, so simplex: close the script by adding </script> to the fx: 'fade', speed: 2500 part.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#48 2009-10-13 11:47:34

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

Re: Using jquery for fading in and out articles (like a flash banner)

uli wrote:

Gallex, so simplex: close the script by adding </script> to the fx: 'fade', speed: 2500 part.

good morning… :) thank’s again uli!
yessss!

Offline

Board footer

Powered by FluxBB