Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-07-29 16:54:37

mistersugar
Member
From: North Carolina
Registered: 2004-04-13
Posts: 157
Website

Add ability to toggle a subparagraph

I like the paragraph toggle that Dave Winer uses on his blog — for example — and wonder where I’d start to have similar functionality in Txp. Is there a plugin, or code? (I’ve not done any jquery coding, so that would be new to me.)

Last edited by mistersugar (2011-07-29 16:55:09)

Offline

#2 2011-07-29 17:08:06

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 596
Website

Re: Add ability to toggle a subparagraph

In your <head>, somewhere after jQuery is included:

<script type="text/javascript">
    jQuery(document).ready(function(){
	$('.post .subsection').click(function() {
		$(this).next().toggle('slow');
		return false;
	}).next().hide();
    });
    </script>

This assumes your articles are wrapped in some element (like a div) with class=“post”.

In your CSS:

.subsection-content {display:none}

In your article:

h3(subsection). Click here for additional notes on the topic.
p(subsection-content). Here is the additional content.

I’ll let you take it from there…CSS styling or whatever…but that’s a simple way to do it.

Reference

Last edited by maruchan (2011-07-29 17:10:03)

Offline

#3 2011-07-29 18:33:39

mistersugar
Member
From: North Carolina
Registered: 2004-04-13
Posts: 157
Website

Re: Add ability to toggle a subparagraph

Thanks. Will try this tonight.

Offline

Board footer

Powered by FluxBB