Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-05-30 00:10:26

detail
Member
From: geez, I seem to be in NZ
Registered: 2010-07-13
Posts: 177
Website

Different javascript slideshow in middle of 14 separate articles

Every now and again there’s some goose, ie, me, who wants to do something that’s just a little beyond their knowledge.

I’ve been playing around with slide shows for a while now and have got a few working by writing the code into the appropriate page.

I want to be able to get a separate javascript popup slideshow on each of 14 articles in the same section. And there are up to 50 images per slideshow.

Doesn’t seem to be working so I wonder if there is a technical limitation with txp about writing js in the middle of an article?

The js slideshow in question is the crudely named fancybox2.

I guess the alternative is to create a custom field, then each article can have a galley the same name as the custom field.

Just not so sure how to pop the slideshow in the middle of the individual article.

Edit: Actually the question is, “can you plop js in an article?”

Last edited by detail (2014-05-30 03:32:58)

Offline

#2 2014-05-30 06:48:12

CodeWalker
Member
From: Hampshire, UK
Registered: 2010-01-08
Posts: 110
Website

Re: Different javascript slideshow in middle of 14 separate articles

Hmm tricky one. You need some kind of hook to output the slides how in the body.

I have done things like this before with step dawsons smd_macro plugins which allows you to write your rags. Give that a go.

Basically it let’s you turn a form into a tag and then u can pass option through the tag.

This means you can write your special tag in the body of an article and pass the image category through the tag and Hey presto.

Much cleaner then a shed load of html in article.

Last edited by CodeWalker (2014-05-30 06:56:02)

Offline

#3 2014-05-30 07:48:12

detail
Member
From: geez, I seem to be in NZ
Registered: 2010-07-13
Posts: 177
Website

Re: Different javascript slideshow in middle of 14 separate articles

detail wrote #281125:

the question is, “can you plop js in an article?”

Looks as if I’ve answered my own question.

Ain’t so easy as an article is formatted in textile, which doesn’t seem to want to switch off, so you get the textile formatting in the middle of the js.

So, no.

Looks like the slideshow will have to go at the end of the article, there’s only one column, and I’ll have a custom field for the gallery name.

Last edited by detail (2014-05-30 07:48:59)

Offline

#4 2014-05-30 07:53:13

detail
Member
From: geez, I seem to be in NZ
Registered: 2010-07-13
Posts: 177
Website

Re: Different javascript slideshow in middle of 14 separate articles

CodeWalker wrote #281132:

This means you can write your special tag in the body of an article and pass the image category through the tag and Hey presto.

Yeah, I’m a big user of txp:smd_gallery in various complex ways, it can do just about anything, other than this instance in the middle of an article with a lightbox.

Offline

#5 2014-05-30 08:02:36

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

Re: Different javascript slideshow in middle of 14 separate articles

detail wrote #281135:

Ain’t so easy as an article is formatted in textile, which doesn’t seem to want to switch off, so you get the textile formatting in the middle of the js. So, no.

So, yes in fact, it just takes some skulduggery. You need to switch off Textile for that instance, which is fine if you’re ok with it, but not so nice for clients. In those cases, you’re probably better off either using smd_macro to write your own tag, or using <txp:output_form/> to render the form contents (you can use custom fields and read them into the form to make dynamic content), which then won’t be subjected to Textile’s mangling ways.

Alternatively, try any of these ‘escaping’ mechanisms:

notextile. <your stuff here>
notextile.. <your multi-line

content
with possible

line breaks

here>
==<your content here>==
 <your content here, with a space or two preceding it>

Hope some of that helps.


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

#6 2014-05-30 08:08:44

detail
Member
From: geez, I seem to be in NZ
Registered: 2010-07-13
Posts: 177
Website

Re: Different javascript slideshow in middle of 14 separate articles

Bloke wrote #281138:

So, yes in fact, it just takes some skulduggery.

Ah, skulduggery, no wonder I didn’t think of it. We’re an innocent lot over this side of the world although I can’t speak for the Aussies.

Thanks Bloke.

PS, at least I’m not being told off for trying js in an article.

Offline

#7 2014-05-30 08:30:23

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

Re: Different javascript slideshow in middle of 14 separate articles

detail wrote #281139:

PS, at least I’m not being told off for trying js in an article.

you could of course use a custom field with a value as it will make it easier for a future site maintenance/upgrade/whatever . Something like

<txp:if_custom_field name="js" value="js"><script>my js</script></txp:if_custom_field>

would work


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

Offline

#8 2014-05-30 08:57:40

detail
Member
From: geez, I seem to be in NZ
Registered: 2010-07-13
Posts: 177
Website

Re: Different javascript slideshow in middle of 14 separate articles

Y

You are of course right.

At the moment this is working . . .

    notextile.. 
    <div>
    <a  class="nwc" rel="gallery02" href="http://tramping.net.nz/images/716.jpg">
    <img src="http://tramping.net.nz/images/716t.jpg" width="300" height="139" title="Click to see slideshow | Northwest circuit, Rakiura National Park, Stewart Island" alt="Northwest circuit, Rakiura National Park, Stewart Island"  /> </a>

    <script type="text/javascript">
    $(".nwc").click(function() {   
    $.fancybox.open(  
    <txp:smd_gallery category="nwc-gallery"  delim="@" paramdelim="|" collate="1" 
    combo='sc_img| { href: "{url}", title: "{caption}" }'>
    [ {sc_img} ],
    </txp:smd_gallery> 
    { padding : 0 
    }); 
    return false;  
    }); </script>
    </div>

I guess there is only one person on the globe who fully understands what that coding really means and I don’t think it’s me. Life is too short to worry about the difference between curly, square and rounded brackets and the spacing requirements for each.

There are so many variables to insert, ie, the anchor links x 2, the title, the alt, the class, and the category, that’s 6 custom fields where I would have to insert the same info anyway, it might be quicker to just set them up manually where at least I can work out what to do. Good ol’ copy and paste.

After all, I have another 13 × 40 image slideshows to set up: choose the image, resize, crop, tweek, sharpen, title and upload.

Time to turn up the music.

Offline

#9 2014-05-31 03:35:57

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,477

Re: Different javascript slideshow in middle of 14 separate articles

I think the solution is much simpler. First, you have to install the smd_macro plugin.

Then you create a own tag, for example <txp:gallery /> to call the gallery code. If you select the images through the ID, then you can use the article image field. If you select the images through categories, then you extend the tag to <txp:gallery category="" />.

In the <head> you only need the following code snippet (see how to):

$(function() {
	$("selector").fancybox();
});

So you can insert the new tag in the article text where you need it:

Article text

<txp:gallery category="images category" />

Article text

Nothing more.

Offline

Board footer

Powered by FluxBB