• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Alternative to StartExpandCollapse tag -- Questions module example
PostPosted: Tue Nov 13, 2007 3:59 am 
Offline
Forum Members
Forum Members

Joined: Tue Jul 17, 2007 1:25 pm
Posts: 43
Location: Rochester, NY
If you are like me and do not like the behavior of the StartExpandCollapse tag -- which adds an anchor link to the collapsable element and always jumps to it -- here is an alternative using a simple javascript.

\$1:
{literal}
<__script__ type="text/JavaScript">
<!--
// TO COLLAPSE/EXPAND ELEMENT
function expand(ind)

{
 e = document.getElementById("ex_"+ ind);
 if (e.style.display == 'none')
 {
   e.style.display = 'block';
 }
 else if (e.style.display == 'block')
 {
   e.style.display = 'none';
 }
}
//-->
</__script>
{/literal}

{foreach from=$items item=entry}
   <div class="QandA-Question">
      <a href="javascript:expand({$entry->id})">{$entry->question}</a>
   </div>
   <div id="ex_{$entry->id}" style="display:none" class="QandA-Answer">
      {if $entry->answer}{$entry->answer}
      {else}<p>Question to be answered soon.</p>
      {/if}
   </div>
   <p class="QandA-RecordDetails">Category: {$param_category} | Question from {$entry->author} on {$entry->created|date_format}</p>
{/foreach}


It can also be helpful for those facing an issue of variables that -- it seems -- cannot be converted as strings in PHP 5.2.0+ as described in the following post:

[url=http://forum.cmsmadesimple.org/index.php/topic,16483.msg81626.html#msg81626]
http://forum.cmsmadesimple.org/index.ph ... l#msg81626
[/url]



michel

_________________


Michel Godts eDesign
Web Graphic Design Services for Your Online Communication

Made with CMSms:
Concentus Women’s Chorus
Color Brighton Green


Last edited by michelG on Tue Nov 13, 2007 4:05 am, edited 1 time in total.

Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Alternative to StartExpandCollapse tag -- Questions module example
PostPosted: Mon Jun 08, 2009 5:28 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 8166
Location: Fernie British Columbia, Canada
This should be trivial with jquery....
(untested, but should be close)

\$1:
{literal}
<__script__ type="text/JavaScript">
<!--
document.ready(function() {
  jQuery('.expandcollapse').click(function() {
     this.toggle('slow');
     return false;
  });
});
//-->
</__script>
{/literal}

{foreach from=$items item=entry}
   <div class="QandA-Question">
      <a class="expandcollapse" href="#">{$entry->question}</a>
   </div>
   <div id="ex_{$entry->id}" style="display:none" class="QandA-Answer">
      {if $entry->answer}{$entry->answer}
      {else}<p>Question to be answered soon.</p>
      {/if}
   </div>
   <p class="QandA-RecordDetails">Category: {$param_category} | Question from {$entry->author} on {$entry->created|date_format}</p>
{/foreach}

_________________
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Alternative to StartExpandCollapse tag -- Questions module example
PostPosted: Mon Jun 08, 2009 6:24 pm 
Offline
Power Poster
Power Poster

Joined: Mon Jun 12, 2006 9:02 pm
Posts: 1900
thanks to you both, Calguy and nkoren!  The "jump" in the original startExpandCollapse tag has always irritated me, but I never had the time/inclination to fix it.

Perhaps one of these fixes should be applied to the startExpandCollapse tag in a future CMSMS release?  The disadvantage (I think, not having looked at the sEC code) is that both of these solutions require Javascript turned on, while the original code does not?  Or maybe the original does...


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Alternative to StartExpandCollapse tag -- Questions module example
PostPosted: Tue Mar 02, 2010 11:27 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Wed Aug 01, 2007 5:36 pm
Posts: 505
Only for reference: see also this related topic
http://forum.cmsmadesimple.org/index.php/topic,5385.msg96710.html#msg96710

regards
blast


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Alternative to StartExpandCollapse tag -- Questions modu
PostPosted: Tue Sep 24, 2013 3:08 pm 
Offline
Dev Team Member
Dev Team Member

Joined: Tue Nov 21, 2006 5:05 pm
Posts: 731
Location: OH, USA
blast2007 \blast2007:

...link should point to viewtopic.php?f=4&t=5385 since forum changes


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
A2 Hosting