Collapsible forum containers

grn - August 4, 2008 - 19:47
Project:Advanced Forum
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Development of collapsible forum containers functionality.

I think it would be cool to develop it with JS or JQuery. Michelle told me that JQuery would be the Drupal way. I will concentrate og figuring out JQuery and how to implement it with the advanced forum module.

Related resources: http://drupal.org/node/202542

#1

Michelle - August 4, 2008 - 20:22

Thanks for doing this. :)

Michelle

#2

grn - August 17, 2008 - 11:58

The first version of the collapsible forum container can be previewed here: http://grn.dk/drupal02/forum

I have only modified the advf-forum-list.tpl.php (attached), with a comment "collapsible container" every time I have modified something. This means that this is pretty ugly at the moment and the jQuery feature is static, inline, and it's only being tested on a forum with only 0-level/depth containers. There is some inline CSS that must be moved.

Next I will add a description of what I have done and a todo list.

Any comments or improvements are always welcome :-)

AttachmentSize
advf-forum-list.tpl_.php_.txt 4.66 KB

#3

Psicomante - August 7, 2008 - 18:23

wonderful! Can we add +/- icons?

#4

Michelle - August 7, 2008 - 18:29
Status:active» needs review

Changing status so I can find it easier. It may be a bit until I can get to this, unfortunately.

Michelle

#5

grn - August 7, 2008 - 20:42

Hey Psicomante

Yes.

#6

Psicomante - August 8, 2008 - 11:25

Modified the two parts of this file. Attached images. I've learned a bit of jquery to make this patch, i hope that this "patch" is not so bad :)

I'm thinkin a way to add automatic ID and function to the containers. Icons path should be dynamic also (i think drupal_path functions or similar are the correct functions...i'll see API)

<div class="name"><a href="<?php print $forum->link; ?>"><?php print $forum->name; ?></a> <?php if ($forum->is_container) print "<span id=\"containerID-".$container."\" style=\"margin:0 1em 0 0; float: right;cursor: pointer;\"><img id='toggleImage-".$container."' src='sites/all/modules/advanced_forum/themes/advforum/images/minimize.gif'></span>";?><!--collapsible container--></div>

<?php
//collapsible container jQuery
drupal_add_js (
   
       
'$(document).ready(function() {
        $(\'#containerID-1\').click(function(){
        $(\'.forum-child-1\').toggle();
        if($(\'img#toggleImage-1\').attr("src") == \'sites/all/modules/advanced_forum/themes/advforum/images/minimize.gif\'){
          $("img#toggleImage-1").attr("src","sites/all/modules/advanced_forum/themes/advforum/images/maximize.gif");
        }else{
          $(\'img#toggleImage-1\').attr("src","sites/all/modules/advanced_forum/themes/advforum/images/minimize.gif");
        }
      });
          return false;
        });'
,
       
'inline'
);
?>

AttachmentSize
minimize.gif 64 bytes
maximize.gif 67 bytes

#7

grn - August 8, 2008 - 18:36

Hey Psicomante, it looks nice.

I tried it out.

Please validate your content at: http://validator.w3.org/

#8

grn - August 29, 2008 - 18:20

I have attached a description of the patch so far.

To do list:

At all times respect the markup: Doctype: XHTML 1.0 Strict. Show how it works at a test site, currently at http://grn.dk/drupal02/forum , and adv forum settings at http://grn.dk/drupal02/admin/settings/advanced-forum.
At all times respect the development and don't make changes that ruin the current features (unless this is agreed by majority).

  • Complete: 2008-08-10: Make the jQuery dynamic by counting forum containers at the beginning.
  • Complete (Wrong assumption): 2008-08-12 Figure out how to do this with multiple container levels. I think this works pretty well at the current state. Forums at all container levels are collapsible. Containers should never collapse (correct me if it's stupid ;-) ).
  • Complete: 2008-08-17 (Added array at settings page): Setup simple initial collapsing options.
  • Complete: 2008-08-20 (Added a ZIP file with the modified files):Put the CSS in the CSS files: advanced_forum.css and advanced_forum-structure.css.
  • Put the jQuery somewhere nice?
  • Complete: 2008-08-21 (Added the advanced_forum_6.x-1.0-alpha2_collapsible_containers.patch): Make a working patch. Apply it with patch -p0 < advanced_forum_6.x-1.0-alpha2_collapsible_containers.patch from the sites/all/modules folder
  • Complete: 2008-08-23 (Added the 2008-08-23_advanced_forum_6.x-1.0-alpha2_collapsible_containers.patch): Remember collapse settings with cookies. This patch needs jQuery Cookie (http://plugins.jquery.com/project/cookie) which can be implemented through the Drupal module jQuery plugins (http://drupal.org/project/jquery_plugin). At this time it is required to save http://plugins.jquery.com/files/jquery.cookie.js.txt as jquery.cookie.min.js in the drupal module folder jquery_plugin.
  • Complete: 2008-08-24: Icons added (change setting in advanced forum settings), remember to add maximize.gif and minimize.gif form (#6). The container table row is clickable, thanks to (http://codex.gallery2.org/GMC:Website:Collapsible_Forum_Containers).
  • Find a nice way for users to specify which folders to collapse as default.
  • Implement further improvements.

Hmm I thought I could put this to do list at the top.... but failed. The description is not editable.

Note, the up to date files for my dev are here at comment #8.

AttachmentSize
collapsible_forum_containers-description-old.txt 2.17 KB
2008-08-20_advforumcollapcontainers.zip 14.28 KB
advanced_forum_6.x-1.0-alpha2_collapsible_containers.patch 4.94 KB
2008-08-24_advanced_forum_6.x-1.0-alpha2_collapsible_containers.patch 6.92 KB
2008-08-29_advanced_forum_6.x-1.0-alpha2_collapsible_containers.patch 7.15 KB

#9

Michelle - August 9, 2008 - 18:15

Very nice! Don't worry about making a patch top priority. I have some client work I need to do before I can work on the module again so it'll be a while before I can get it in anyway.

Thanks!

Michelle

#10

Michelle - August 10, 2008 - 14:25

Ok, so I was supposed to do some client work this weekend but worked on advforum instead. So I got a bunch of stuff fixed and want to make a new set of alphas sometime this week. Any ETA on this? Do you think it will be ready to be included?

Thanks,

Michelle

#11

grn - August 10, 2008 - 18:36

Hey.

I expected some more interest from others to support the development. It was intended as a kickstart. I will be working on this, but I don't think I will finish this week.

It could be included as it is. What do you need?

Thanks.

#12

Michelle - August 11, 2008 - 01:33

Getting others to support development beyond saying "+1" can be hard... That's why I'm excited that you took on this part. ;)

If you think it's at a usable point, I just need the current code.

Thanks :)

Michelle

#13

grn - August 11, 2008 - 05:40

For forum containers at level zero it works pretty fine.

The current code is in #8 (advf-forum-list.tpl_.php_.txt). Please specify if it should be presented to you otherwise.

#14

Psicomante - August 11, 2008 - 15:03

did you add my patch?

#15

grn - August 11, 2008 - 18:22

I will add the patch if someone makes it XHTML valid.

#16

Psicomante - August 11, 2008 - 22:34

done it!

<div class="name"><a href="<?php print $forum->link; ?>"><?php print $forum->name; ?></a> <?php if ($forum->is_container) print "<span id=\"containerID-".$container."\" style=\"margin:0 1em 0 0; float: right;cursor: pointer;\"><img id='toggleImage-".$container."' src=\"sites/all/modules/advanced_forum/themes/advforum/images/minimize.gif\" alt=\"Show or hide the forum\" /></span>";?><!--collapsible container--></div>

<?php
//collapsible container jQuery
drupal_add_js (
   
       
'$(document).ready(function() {
        $(\'#containerID-1\').click(function(){
        $(\'.forum-child-1\').toggle();
        if($(\'img#toggleImage-1\').attr("src") == "sites/all/modules/advanced_forum/themes/advforum/images/minimize.gif"){
          $("img#toggleImage-1").attr("src","sites/all/modules/advanced_forum/themes/advforum/images/maximize.gif");
        }else{
          $(\'img#toggleImage-1\').attr("src","sites/all/modules/advanced_forum/themes/advforum/images/minimize.gif");
        }
      });
          return false;
        });'
,
       
'inline'
);
?>

#17

grn - August 12, 2008 - 16:42

Nice work with the validation Psicomante.

We have an additional problem before this is applicable. We must have an intelligent way to identify which containers are collapsed or else we can get a problem with the +/- icons (attached: 2008-08-12_plusminus_bogus.jpg). The whole fun part about this patch is initially to collapse some or all containers. Your part assumes that all forums are uncollapsed.

*EDIT* I have attached advf-forum-list.tpl.php.plusminus_bogus.txt.

AttachmentSize
2008-08-12_plusminus_bogus.jpg 30.9 KB
advf-forum-list.tpl_.php_.plusminus_bogus.txt 6.04 KB

#18

Psicomante - August 12, 2008 - 16:57

i thought about it yesterday. I think there's a better way to do this: using css classes and recycle code from collapse function.

#19

jannalexx - August 13, 2008 - 16:00
Version:6.x-1.x-dev» 5.x-1.0-alpha10

#18
advf-forum-list.tpl_.php_.plusminus_bogus.txt
tested and also have the same issues/bugs

a nice implementation is here
http://gallery.menalto.com/forum

you can think some code functions to use "all shown" at the beginning or "all hidden" or "hide some individual" containers by an array of numbers for eatch container (eg 1,5,6,8...) for each forum list in that order
every new container can also follow a rule (new collapsed or shown) and then if needed, it can be included manualy in the code as (last) number in the array, just a simple idea.

#20

grn - August 20, 2008 - 18:51

Gallery has a nice forum. We should spend more time studying it. We could apply some of the features as described here: http://codex.gallery2.org/GMC:Website:Collapsible_Forum_Containers

Remark, status and my latest dev files can be found at #8 (http://drupal.org/comment/reply/291084#comment-957056).

I will look into making a "real" patch now.

#21

Michelle - August 20, 2008 - 19:21

Yeah, the Gallery forums have long been an inspiration to me. I actually have a copy of their theme from a while back so I could look at the custom code in the forum. (Not allowed to give it out, though.)

Just so you know, I'm not ignoring this issue. Just need to get the style revamp done before I can implement this.

Michelle

#22

grn - August 23, 2008 - 15:34
Version:5.x-1.0-alpha10» 6.x-1.0-alpha2

I have added jQuery Cookie to remember collapse states of the containers (at #8).

It works fine in Firefox 3.01, but in Opera 9.50 the cookies are lost after browser restart (probably a strange browser setting).

Please report any errors encountered and guide me in the right direction, because I think the code I have written sucks ;-)

Next I am hoping to get the adv_forum settings page to display all containers and the abillity to collapse at default (not only all collapsed or expanded). I need to get the names and number of containers from the forum list at module level. I could use a hint from Michelle here or somebody else :-)

#23

grn - August 24, 2008 - 09:34

Collapsible forum Status

Settings:

  • Choose collapse state: All collapsed (default); None collapsed
  • Use icons?: Yes (default); No
  • New features:

  • Icons added.
  • Container table row is clickable.
  • At #8 (http://drupal.org/node/291084#comment-957056).

    #24

    Psicomante - August 27, 2008 - 14:43

    Great work! Are you sure to make jquery_plugin Module a "dependence" (i'm not sure this is the correct term)?

    Are there the last patched files?

    #25

    grn - August 27, 2008 - 14:48

    Hey.

    1) jQuery plugin module is required to get jQuery cookie to work. I am not sure I have answered your question?

    2) I am not providing patched files anymore only patches. I am thinking of the unnecessary traffic.

    #26

    Michelle - August 27, 2008 - 15:23

    grn - Sorry, I missed your question. The forum container names can be gotten with variable_get('forum_containers', array());

    Michelle

    #27

    grn - August 27, 2008 - 17:56

    Thanks, I will look into it.

    #28

    Michelle - August 29, 2008 - 18:31

    Just want to say thanks for your continuing work on this. I don't want you to get discouraged that it's not in, yet. I will add it. Just getting time to work on advforum has been rough lately. :(

    Michelle

    #29

    Psicomante - August 29, 2008 - 20:02

    Find a nice way for users to specify which folders to collapse as default.

    The only way that i find is: save on profile or in other table a array of collapsed forum for every users. Mmmm is this so necessary?

    @grn. I saw the todo list, but i haven't tried the patch yet. Is there something doesn't work?

    #30

    grn - August 30, 2008 - 15:55

    Michelle don't worry about that :-) I just needed this for my own benefit ;-)

    Psicomante - I will add an option for admin to customize wich containers to collapse from the settings page. The latest version of the patch should work pretty well. I don't know about the cookies in some browsers. The adv forum will depend on jQuery plugins if this is implemented as it is. The big problem is that jQuery isn't quite ready for this yet. jQuery Cookie isn't implemented in jQuery plugins (http://drupal.org/node/298847). jQuery plugins will implement jQuery Cookie if the jQuery module is merged with jQuery plugins. The jQuery Cookie module won't answer my request. The status is random ;-) (http://drupal.org/node/298962).

    #31

    grn - September 2, 2008 - 20:34

    Find a nice way for users to specify which folders to collapse as default.

    I am trying to get the forum container names from forum_containers.

    $containers = variable_get('forum_containers', array());
      foreach ($containers as $container)echo $container." <br />";

    But I am missing something here..... (not $container.. but something like $container->name).

    #32

    Michelle - September 2, 2008 - 21:23

    I'm getting close to being ready to tackle this but I'm confused on which code I should be using. Could you add a new comment with the latest code when you get a chance?

    Michelle

    #33

    grn - September 3, 2008 - 09:33

    This is the latest patch.

    AttachmentSize
    2008-08-29_advanced_forum_6.x-1.0-alpha2_collapsible_containers.patch 7.15 KB

    #34

    jannalexx - September 7, 2008 - 11:13

    what about 5.x ?

    #35

    grn - September 7, 2008 - 11:31

    You could check out the patch, and try to implement the same changes to 5.x. I won't support 5.x...

    #36

    Michelle - September 8, 2008 - 04:31
    Status:needs review» needs work

    Ok, I spent quite some time tonight trying to work this patch in. Unfortunately, I can't use it as is so I've been trying to understand how it all works and put the pieces in the proper spots. I ran out of time tonight and don't want to commit my half done mangled mess but I wanted to let you know that I am at least working on it. :)

    Michelle

    #37

    Michelle - September 8, 2008 - 13:33

    Ok, I've spent about two hours on this and I can't afford to take any more time for it right now. I appreciate your work, but this patch just isn't usable as is. Part of that is my fault as I've changed the .tpl so it doesn't apply but even besides that there are too many issues:

    • The code doesn't conform to Drupal's coding standards
    • Adding an option just for whether they want to use icons in this one spot isn't going to work. That should be handled in the theming. Also, image paths can't be hardcoded.
    • There is a huge chunk of code being added to the top of the .tpl. Template files should have minimal amounts of code. This needs to be worked into the preprocess code as much as possible or into the existing foreach array in the template for anything that can't be put in the preprocess.
    • jquery code is normally put in a seperate .js file. I don't know jquery so maybe there's some reason why this needs to be inline but, if at all possible, it should be separated out.
    • <a onclick="event.cancelBubble = true" doesn't appear related to this issue.

    I realize you did this for your own use and I understand if you don't want to take the time to fix it up for general use, but it would be great if you could since this is a feature I'd like to have included.

    Thanks,

    Michelle

    #38

    Michelle - September 8, 2008 - 15:16

    Actually, hold that thought. I was thinking about this in the shower and I think I have a much easier way to do this. My knowledge of jquery is rudimentary but I think it will work. I can't try it out until later today, though.

    Michelle

    #39

    grn - September 8, 2008 - 20:15

    Hey.

    I didn't know the Drupal coding standards, so it isn't the way it should be. One standard that annoys me is the "two space" tab, which I will fix in the future with search and replace. It's cool to have standards, but what it is the reason for this (out of topic - ignore ;-) )?

    I put the jQuery inline because I didn't/don't know how to include it otherwise.

    The goal is to implement this feature in the official advanced forum release, so it will be easier for me to maintain ;-)

    I can work on the issues you mentioned if you like.

    #40

    Michelle - September 8, 2008 - 20:44

    Ok, I worked on this some more during nap time. I don't know jquery, but I have a general understanding of how it targets things so hopefully the changes I made will be helpful.

    • Added advanced_forum.js. You can put your functions in here and they will be included.
    • Added your icons as container_close.gif and container_open.gif in the naked style.
    • Added a class to each container of "container-N" where N is the TID of the container. I used the TID rather than its position so settings will still work even if they get moved around. Plus it will make it easier to specify a list of open/closed containers in admin at some point.
    • Added a class to each forum of "in-container-N" where N is the TID of the containing container. There is a bug at the moment where you end up with just "in-container-" for forums at root. I plan to change that to "in-container-none".
    • Added <span id="collapse-toggle-N"> where N the TID of the containing container. This is for adding the +/- like you have in your class.

    These changes are in CVS and will be in the tarball in about 3 hours. I haven't added any of the jquery at this point. I'm hoping you can use these classes to target your jquery. If you're willing, I'd like to work together on this and have you write the jquery and just tell me what you need in the PHP end and I will make it happen. If you need more classes to be able to target things better, just let me know.

    BTW, I read the Gallery page and figured out what that bubble bit was for. :)

    Thanks again for your work on this. My intent isn't to just discard all your work. In fact, I've spent quite a bit of time studying it and trying to figure out what you did but the jquery is just beyond me at this point.

    Michelle

    #41

    grn - September 8, 2008 - 20:52

    Thats Cool.

    I don't have a personal relationship with my code. I just wan't things done :-)

    I would be happy to work together with you on this. I think I will have some time tomorrow to work on this.

    By the way, the icons (and most icons code) are provided by Psicomante.

    #42

    Michelle - September 9, 2008 - 03:41

    Sounds great. I'll make sure to add credit for the icons to Psicomante. I've got a second issue about documenting icon sources so it will be taken care of with that.

    Michelle

    #43

    Psicomante - September 9, 2008 - 08:40

    Thanks grn, but my work was very simple related to yours. Anyway i'm thinking about providing better icons for minimize and maximize. When they will be ready, i'll attach them here.

    #44

    grn - September 12, 2008 - 20:49

    Hmm, I have been working on this issue today.

    I am not sure I have the right solution for this.

    I figure that I we will need "something" to generate the dynamic jQuery code.

    At first we could make something like this in advanced_forum.js:

    $("#forum-list-N").click(function() {
      $(".in-container-N").toggle()
      if($.cookie("cookie_container-N") !== "collapsed") {
        $.cookie("cookie_container-N", "collapsed");
      }
      else {
        $.cookie("cookie_container-N", "expanded");
      }
    });

    Where N should be the tid, but how can I fetch that from the javascript file? Or should the jQuery functions be fetched by the php code somehow in the preprocess?

    An other issue is to get jQuery cookie included. How do we plan to do that? In the old version it was handled by: jquery_plugin_add("cookie");

    #45

    grn - September 10, 2008 - 14:53

    I have attached a hardcoded .js. Collapsing works fine as far as I can test. The cookie function is not working.

    AttachmentSize
    advanced_forum.js_.txt 552 bytes

    #46

    Michelle - September 10, 2008 - 15:16

    I tried rustling up someone on IRC that can help with this. No luck so far. Will try again this afternoon. I'm headed out of the house for a while.

    Michelle

    #47

    cridenour - September 11, 2008 - 15:58

    Well you could generalize the function and set an event listener on the elements you want for the onclick (meaning it doesn't have to be a link/image - things like table rows should work)

    I think to create that function for each topic would be bad, bad, bad.

    #48

    neclimdul - September 11, 2008 - 16:01

    yuck... cookies everywhere? your users have to send those to the server on every request.

    There's got to be a better way.

    #49

    grn - September 11, 2008 - 16:10

    Hmm I am not folowing you?

    We aren't working on a function for each topic, it is bound to each container ID and every forum in that container as a CLASS.

    It's cool that you think it's bad and yuck and you think there is a better way. Nobody has done it here before, but all suggestions are welcome.

    By the way, the php working with javascript could be done with ajax, but i haven't worked with that yet.

    #50

    cridenour - September 11, 2008 - 17:19

    grn:

    You asked how you could avoid hard-coding each collapse/expand call. I suggest making it a static function.

    #51

    grn - September 11, 2008 - 17:28

    cridenour - I don't know how this should work when the containers are dynamic. I think i am focusing in the wrong direction and this blinds my imagination.

    #52

    Michelle - September 11, 2008 - 17:41

    I'm rather working in the dark because I only have a theoretical knowledge of jquery, but...

    How about if I put some sort of "onclick" code on each container's TR/TD that sends the TID to a jquery function? Since all the forum TRs are classed with in-container-TID you can to target them from that.

    We'd also need a function on page load that will set up the collapsed state according to 1st the user's cookie and 2nd, if no cookie, the states set up by the admin. On the admin side, I can store a set of TIDs that should be collapsed. Assume any not in that set are uncollapsed. I don't know how jquery cookies work but it seems like you should be able to do the same there. So the onload jquery code would just read the set of collapsed containers and hide them.

    Seems simple enough but, then, I don't know how to execute it so maybe I'm way off base. LOL

    Thanks,

    Michelle

    #53

    cridenour - September 11, 2008 - 22:02

    Michelle:

    That is exactly how I would have approached.

    I'll look into the jQuery later this evening.

    #54

    grn - September 13, 2008 - 14:41

    Thanks for clearing my mind :-)

    I hope the folowing is going in the right direction.

    In adv-forum-list.tpl.php add this code in the container element:

    <?php print 'onClick="jq_collapse(\''.$child_id.'\')"';?>

    With the attached js file, we should have some functionality.

    Please feedback on this when you get the time :-)

    AttachmentSize
    advanced_forum.js_.txt 408 bytes

    #55

    Michelle - September 13, 2008 - 20:03

    I can't get that to work... Can you have a look at http://6dev.shellmultimedia.com/forum and tell me if I put the jquery in the right spot?

    Michelle

    #56

    grn - September 13, 2008 - 21:19

    The collapsing is working here in Opera and Firefox (very buggy at the moment). It's just a test case.

    You must click on the row twice.

    #57

    Michelle - September 13, 2008 - 21:50

    Well, color me confused. It is working for me, now, too. I can open and close them with just one click. So we just need something for the +/- icons, then. Awesome work!

    Michelle

    #58

    jannalexx - September 13, 2008 - 22:55

    nice approach..
    can you please point a delicate way to load the javascript "advanced_forum.js" on 5.x (and 6.x if different)?

    #59

    Michelle - September 14, 2008 - 03:14

    @jannalexx - It's loaded via drupal_add_js.

    @grn - Ok, so here's the "to do" as I see it:

    • Add a function to set the initial collapsed state. This should look first at cookies and, if no cookies, at a list stored in a Drupal variable.
    • When you click on a link in the container, it opens/closes the container. I believe that's what that "bubble" thing was meant to fix.
    • Add the +/- icons and have them change depending on the container's collapsed state.

    Anything I'm missing? Are you able to tackle these?

    Thanks!

    Michelle

    #60

    grn - September 14, 2008 - 08:38

    Michelle: This should be simple. The right approach is a bit trickier....

    We have an extra </div> at line 94.

    Why do we want a span

    <span id="collapse-toggle-<?php print $forum->container_id;?>"></span>

    and not an img?

    <img id="collapse-toggle-<?php print $forum->container_id;?>" src="images/container_close.gif" alt="Show or hide the forum" />

    What is the path to container_close.gif?

    I am still having problems with two click enabling the collapse function after page reload (browser cache could be preventing this bug from appearing).

    #61

    grn - September 14, 2008 - 08:59

    Two click bug is now fixed.. why didn't anybody see this??? ;-)

    We don't need: $('#forum-list-' + container_id).click(function() { when the function is called by onclick html. By the way it should be "onclick" not "onClick" my bad..

    AttachmentSize
    advanced_forum.js_.txt 400 bytes

    #62

    grn - September 14, 2008 - 09:11

    I found the path thing: drupal_get_path('module', 'advanced_forum')

    #63

    jannalexx - September 14, 2008 - 09:45

    function advanced_forum_js_load() {
    drupal_add_js(drupal_get_path('module', 'advanced_forum') .'/advanced_forum.js');
    }

    or
    drupal_add_js("sites/all/modules/advanced_forum/advanced_forum.js", 'module');

    But js can't be loaded
    error: jq_collapse is not defined

    (file is in the directory), whats the code in your side?

    #64

    grn - September 14, 2008 - 09:44

    jannalexx: in advanced_forum.module the you can add:

    drupal_add_js(drupal_get_path('module', 'advanced_forum') . '/advanced_forum.js');

    to function advanced_forum_init() {

    Have a look at the latest dev release.

    #65

    grn - September 14, 2008 - 10:12

    Add a function to set the initial collapsed state. This should look first at cookies and, if no cookies, at a list stored in a Drupal variable.

    Hmm I reckon that this function should be loaded at dom.onload or something similar (http://www.geekdaily.net/2007/07/27/javascript-windowonload-is-bad-mkay/). I am struggling to find a way to send the php information to an onload javascript function? It was easy with the onclick, when my mind got cleared.

    The initial collapse state is saved in cookies with jQuery.. maybe this should be handled by php...

    By the way, I think the easiest approach will be to set cookie states for all the containers initially, only overriding user settings if they aren't set.

    #66

    Michelle - September 14, 2008 - 13:44

    @jannalexx - If you're curious about how this is being implemented, please just look at the code so we can keep the issue on topic.

    @grn - I used a span instead of an image for the +/- because that is how you had it in your original code and I thought it needed to be that way. I changed it. You'll need to add the javascript to change from close to open as needed.

    Setting cookies for the initial states sounds fine.

    I have no idea how to send PHP to javascript. I'll see if I can rustle up some help for that.

    Changes so far committed.

    Thanks,

    Michelle

    #67

    cridenour - September 14, 2008 - 15:45

    Sorry I disappeared the past few days!

    I think grn is on the right approach. Have the JS read from the cookie. Have PHP set the cookie from the DB if one doesn't exist.

    This way, you have the option of talking both ways (anything the JS does could eventually be read by the PHP).

    #68

    grn - September 14, 2008 - 17:04

    In advanced_forum_init() { add jquery_plugin_add("cookie");.

    I have attached a new js file. This will change the image appropriately.

    In the list.tpl.php you should have the looking like this:

    <img id="collapse-toggle-<?php print $forum->container_id;?>" src="<?php print
                    
    drupal_get_path('module', 'advanced_forum') . '/styles/naked/images/container_close.gif';?>
    " alt="Show or hide the forum" />

    This of course assumes initially expanded containers.

    EDIT: The onclick: <?php print 'onclick="jq_collapse(\''.$child_id.'\', \''.drupal_get_path('module', 'advanced_forum').'\')"';?>

    AttachmentSize
    advanced_forum.js_.txt 657 bytes

    #69

    Michelle - September 14, 2008 - 17:06

    jquery_plugin_add("cookie"); is undefined.

    Heading out for a couple hours. If you can tell me how to fix that part, I'll commit the latest when I get back.

    Thanks,

    Michelle

    #70

    grn - September 14, 2008 - 17:12

    The jQuery plugins module must be installed.

    The jQuery Cookie must be manually installed in jQuery plugins. The problem is stated at #30.

    #71

    Michelle - September 14, 2008 - 19:35

    @grn - Oh... Hrm... I missed that when I read through. Is that the only way to do it? If so, I guess I'll just wrap the call in a functon_exists so it doesn't fail for people who don't have the plugin.

    Michelle

    #72

    grn - September 14, 2008 - 20:48

    You could make a duplicate of the jQuery Cookie js file and put it in the adv forum module.. but that's not the way it should be done ;-)

    #73

    Michelle - September 14, 2008 - 20:58

    No, I don't want to do that. I was wondering if there was any way to do it with the jquery available in core. If not, I guess I'll need to include instructions for adding this if people want it. Is there any way to make the +/- change on click so at least that's accurate without cookies?

    Michelle

    #74

    grn - September 15, 2008 - 13:53

    We probably need the jQuery Cookie to communicate between php and jQuery. Without cookies and initial collapse function the container states are a mess. Unless we state that on every pageload, the containers are all collapsed or all expanded. Then the collapse function looses it's value.

    #75

    Michelle - September 15, 2008 - 17:27

    Ok, so how about this for a plan:

    1) Initially assume all containers are open
    2) I will put in the code to use jquery cookie but will check for the presense of the function. If it's there, the code will run to read the state of the forums from the cookie. If it's not there, this step will be skipped.
    3) If the code to read the cookie exists but the cookie itself does not, prefill the cookie with the states from the Drupal variable.
    4) When a user clicks to open/close a container, attempt to write it to the cookie and also target the icon to change it. This way the icon will change whether the cookie code is there or not. Of course, this won't be maintained between page refreshes if there is no cookie code.

    Does this sound like a plan to you? If so, I believe all that I need from you is the code to change the icon on click. I think you have the rest of it working with the cookie if jquery cookie is installed, correct? Also, could you provide instructions for getting jquery cookie working with D6? You said something about copying the code to jquery plugins but I'm not sure what code and where it goes. It looks like the jquery plugins maintainer may be open to adding it but I need to test this in the mean time as I want to do an alpha in the next day or so and this is one of the last remaining issues.

    Thanks,

    Michelle

    #76

    Michelle - September 15, 2008 - 17:31

    Note to self: I also need to finish the work of making collapsable containers optional so I don't have to endure the wrath of Morbus. ;)

    Michelle

    #77

    grn - September 15, 2008 - 17:59

    A) The icon change is in the js at #68... this should work when cookies are enabled, without the cookies the jQuery does not have a chance on figuring out the collapse state.

    B) The major issue is getting the collapse state initially on page refresh. I don't know how to get the container_id's in the jQuery...

    jQuery cookie:
    1) get the jQueryCookie code: http://plugins.jquery.com/project/cookie
    2) put it in the jquery_plugin folder and rename it to "jquery.cookie.min.js"
    3) in advanced_forum.module put jquery_plugin_add("cookie"); in function advanced_forum_init() {

    This should be it. This is not ready for alpha in my opinion.... primarily because of B).

    Please let me know if you need more information. Sorry that I can't figure out the php/jQuery voodoo. I figure we need ajax or something, but I don't know much about it. Maybe some gurus could give us a hint... are we going in the right direction?

    #78

    Michelle - September 15, 2008 - 18:38
    Version:6.x-1.0-alpha2» 6.x-1.x-dev

    A) I admit I don't know jquery but I know enough about it that I don't think it's impossible to toggle between two icons on click without using cookies. I'll see if I can find someone to help with that.

    B) I don't, either. Let's see if I can rustle up some more help.

    Thanks for the tips on getting the cookie working. Hopefully we can get this sorted. I can't keep holding off on this alpha. The last alpha was in June and that's way too long between.

    Michelle

    #79

    grn - September 15, 2008 - 19:01

    A) Yes it worked that way in the early versions of my inline jQuery.. the image src changed every time a toggle was initiated.

    #80

    cridenour - September 16, 2008 - 14:15

    With this new info - I would suggest setting up a new page in your hook_menu to handle AJAX requests. So instead of cookies, you are just speaking to your database. Then on initial load, you can pull the data from the db and populate that into the .tpl file.

    The only reason I suggest this route now is I was unaware (aka didn't read) that using cookies required an additional module. This is unacceptable for such a menial feature.

    #81

    Michelle - September 16, 2008 - 14:37

    @cridenour - Is this something you're able to help with? I know what hook_menu is but I'm really just out of my league with jquery/ajax. As much as I'd love to work through how to do it and learn how to use them, it's just not possible for me right now. Too much on my plate and I really need to get this working ASAP to replace the buggy alphas we have now. If you have the time to swoop in with a patch that makes this work without relying on jcookie or tons of code packed into the .tpl, that would be really awesome. I think we're close in the direction we're going but I just don't have the knowledge to push the rest of the way there.

    Thanks,

    Michelle

    #82

    cridenour - September 16, 2008 - 15:22

    I likely won't be able to write anything until the weekend. If that changes, I'm sure I'll be in IRC but have a presentation on Friday.

    I'll check back here if my schedule opens up in the evenings.

    #83

    cridenour - September 17, 2008 - 05:03
    Assigned to:grn» cridenour
    Status:needs work» needs review

    Attached patch goes against 6--1 Branch.

    Basically we have an onload AJAX call and AJAX calls after each toggle. It sends it to PHP which handles the cookie (or creates on if it does not exist).

    I still need to create the menus to allow the admin to set defaults. However - this could also be done by others - just need to pull down current categories, some checkboxes, serialize the results in a [category_id] => [boolean for collapsed] format :)

    AttachmentSize
    advf-collapse.patch 6.05 KB

    #84

    cridenour - September 17, 2008 - 05:05

    Hmm just noticed I still have some debug comments in there as well...

    And Michelle I will talk with you tomorrow on D5 roll - some of the jQuery changes I believe. I'll need to do some research during lunch.

    #85

    Michelle - September 17, 2008 - 12:36
    Status:needs review» needs work

    Yeah, I can handle the settings page. I was just waiting until this got sorted before adding it.

    The patch looks good. I only have a few nits:

    1. I think the path should be advanced_forum/collapse rather than advf/collapse
    2. The variable should be advanced_forum_collapse_defaults rather than advforum_collapse_defaults
    3. As you said, debugging code needs to be removed
    4. I don't understand the reason for dropping the last div in <div class="num num-topics"><?php print $forum->num_topics ?></div>

    I can take care of the first 3 myself later today if you don't get to it first. The last one needs your input, though. Thanks very much for doing this. :)

    Michelle

    #86

    cridenour - September 17, 2008 - 14:49

    @2
    I was following the advforum_topic_pager_max variable name ... any reason that isn't advanced_form?

    @4
    I wanted Eclipse to stop telling me there was an unclosed div... I meant to ask you about that. There is a mismatched # of divs in that section - there was no collapse reason for it, I just wanted the errors to go away :)

    #87

    Michelle - September 17, 2008 - 15:02

    @2 - That's an error, then. The rest are all advanced_forum. I'll fix that. A lot of those variables just got created on the fly when I decided something should be optional as I wrote it and I must have goofed with that one.

    @4 - Interesting... There should be a closing div there so it's messed up somewhere else. I'll look thru it, thanks.

    Michelle

    #88

    Michelle - September 17, 2008 - 20:35

    Ok, patch in #83 comitted. Thanks for jumping in, cridenour.

    Remaining issues:

    1. Icon doesn't change between +/-
    2. Need to add admin settings for initial states
    3. Forum header jumps sideways when opening/closing containers

    I can do #2 and probably #3 but I need help with #1.

    Thanks,

    Michelle

    #89

    Michelle - September 19, 2008 - 03:35
    Status:needs work» active

    Ok, #2 is done. Still need help with #1.

    Michelle

    #90

    cridenour - September 20, 2008 - 19:22

    #1 done.

    AttachmentSize
    advf-collapse-2.patch 2.01 KB

    #91

    Michelle - September 21, 2008 - 19:15

    When I apply this, the icon changes, which is great, but the states stop getting saved, which is not good. :(

    Michelle

    #92

    cridenour - September 22, 2008 - 12:47

    On what browser? The fox? And I also noticed another little bug in my patch. Not seeing the problems you are though.

    Will re-roll tonight.

    #93

    Michelle - September 22, 2008 - 13:05

    Yes, on FF3. All I did was apply the patch and clear the cache. The icon changed back and forth but as soon as I went to another page and came back, all containers were open again. Reverting the patch made it go back to remembering the container state.

    Thanks,

    Michelle

    #94

    grn - September 22, 2008 - 14:48

    User collapse states are forgotten at page refresh, confirmed in Opera 9.50 and FF 3.01. This is the cookie thing, didn't realize that this was implemented here.

    Nice to see there is progress here :-) Keep up the good work!

    #95

    halkeye - September 22, 2008 - 19:42

    On the admin page (admin/settings/advanced-forum) the $options array was not reset after the theme selector dropdown.

    Line 190 (approx) needs an:
    $options = array();

    before the loop before $form['advanced_forum_collapse_defaults'] = array(

    It is currently:

    Default collapsed containers:
    [ ] naked
    [ ] blue_lagoon
    [ ] cat 1
    ...

    I'll try to checkout the cvs version tonight and make a patch.

    #96

    Michelle - September 23, 2008 - 00:00

    @halkeye - Whoops. Missed that. No need to make a patch. I can fix it. Thanks for letting me know.

    Michelle

    #97

    Michelle - September 25, 2008 - 04:50

    @cridenour - any progress on this? We're almost there. :)

    Thanks,

    Michelle

    #98

    cridenour - September 25, 2008 - 20:31

    In the last few lines, where it pulls the initial state - try chaning container_id to tid (the correct variable name in that function) That might be the problem here.

    Sorry school started up and am organizing a Cincy drupal meetup tonight. :)

    #99

    Michelle - September 28, 2008 - 22:48

    At this point, collapsable containers are totally broken. I'm sure it's my fault. I applied a bunch of E_ALL notice patches from another issue and something in them broke it. But I don't know what happened or how to fix it. I need someone with jquery knowledge to go in and fix the goof and get this all working. Since this isn't likely to happen tonight, I'm going to hold this one over until after the alpha.

    Michelle

    #100

    cridenour - September 29, 2008 - 03:39

    Every time I sat down with it, I got pulled away two-five minutes later. Not sure when my schedule will clear. But this is sitting up near the top when it does.

    I agree on waiting though.

    #101

    Michelle - October 6, 2008 - 19:02
    Priority:normal» critical

    I am going to be releasing a new alpha with just bugfixes as soon as I can get a hold of John Albin and fix the Zen subtheme problem. I need to either have these containers working or I'll need to pull the code out. I've had a couple of people complaining that the unfinished code is causing problems.

    Is anyone going to have time to work on it this week?

    Thanks,

    Michelle

    #102

    Michelle - October 7, 2008 - 13:22

    Should link to the issues I'm duping for this to make sure all problems get fixed...

    #317371: Advanced Forum error on page
    #317008: Fatal error related with collapsible containers

    I really could use help on this issue. I'm waiting on John's help with the Zen subtheme issue this week. Soon as we get that fixed, I'll be rolling a bugfix alpha. If no one has time to get this fixed, I'm just going to take all the code out until someone has time.

    Michelle

    #103

    Michelle - October 7, 2008 - 22:00
    Priority:critical» normal
    Assigned to:cridenour» Anonymous

    And another issue caused by this: #318256: Something is wrong with sitewide pager links

    I've removed all of the code from both branches for collapsable containers. The work isn't lost as it's there in the CVS history. I don't have the js/ajax skills to do this. If someone wants to do this, I'm open to a patch provided it works, follows Drupal coding guidelines, and doesn't cause any of the issues that caused me to remove all the code.

    Thanks to those of you who worked on the code. I do appreciate the effort but I can't leave code in there that causes problems, especially since the code wasn't yet to a working point.

    Michelle

    #104

    cridenour - October 11, 2008 - 16:48

    Sorry I was pulled away from this. Considering I am unable to reproduce any of the errors on my site with the code I wrote against, like you said earlier, something was broken later on.

    The pager links problem is even more confusing to me as it looks like it is appending the cookie to the URL. Maybe once school dies down again, I can approach the problem vs the latest build and find out what went wrong. This one seems to be an issue that might be in core as I'm not doing anything fancy with the cookie but that will have to wait for my schedule to die down.

    Again, I apologize for being pulled away from this lately. As you can tell by my absence in IRC / groups.drupal etc, I am not just ignoring this :)

    Chris

    #105

    Michelle - October 11, 2008 - 17:04
    Category:task» feature request
    Status:active» postponed

    I understand. Real life gets in the way of fun coding a lot. TBH, I don't see this as a critical feature. It's nice, sure, but we can live without it until we have a solid solution. The code is all out of the dev. If anyone is still having pager issues, be sure to clear your cookies.

    I'm going to set this as a postponed feature request until you or some other jquery person can step up and take this home. :)

    Thanks for all the time you folks have put into it.

    Michelle

    #106

    Michelle - October 22, 2008 - 23:04
    Status:postponed» active

    Now that I have alpha 13 out, AF is open to new features again. If anyone wants to work on getting this into alpha 14, feel free. :)

    Michelle

    #107

    akiecs - November 13, 2008 - 03:51

    Will this work on drupal 5?
    I installed alpha 13 on my Drupal 5.12, but I didn't see the option "Default collapsed containers".

    Thanks

    #108

    Michelle - November 13, 2008 - 03:59

    @akiecs - This won't work on either version until someone writes it.

    Michelle

    #109

    grn - November 16, 2008 - 12:20

    Hi.

    If someone wanted to continue the development of this feature, where should that person begin?

    Is it possible to do further work on the buggy code you removed?

    #110

    Michelle - November 16, 2008 - 14:09

    grn - Sure. The code is all either in this issue or in cvs. You can use it as a starting point. I need to be firm on this one, though, because this issue sucked up far too much of my time for such a tiny feature. I'm only willing to look at completed, working patches that follow Drupal's coding standards so I can just apply, test, and commit. Normally I'm willing to spend time helping patches along but I've already spent that time on this one.

    Michelle

    #111

    grn - November 16, 2008 - 16:39

    OK

    #112

    3duardo - November 24, 2008 - 22:20

    subscribing

    #113

    Michelle - December 9, 2008 - 03:57
    Status:active» postponed

    Will revisit this in 2.x.

    Michelle

    #114

    Michelle - May 7, 2009 - 03:07
    Version:6.x-1.x-dev» 6.x-2.x-dev
    Status:postponed» active

    #115

    NeoID - June 14, 2009 - 08:46

    For you still interested in this, I found a nice site about solving this issue: http://www.tobypitman.com/multiple-collapsable-panels-with-cookies/
    I've almost managed to get it to work on the forum, but there are still some problems with it, so I can't release my code-snippet yet.

    I really like the approach, but I'm still struggling on how to access the right ul to hide for each container.
    (See for yourself on the menu to the left on that site)

    #116

    Michelle - June 25, 2009 - 22:00

    Just an FYI: Now that each container is its own table, that may help with this. Now is a good time if anyone wants to have another go at a patch as I'm actively working on 2.x. I still don't know any javascript / jquery so this feature is relying on the community stepping up. :)

    Michelle

    #117

    andrewsuth - July 3, 2009 - 09:23

    Good idea to give each container a table - might this also open the door to making them sortable?

    I will happily test any collapsible patches once 2.x is a little more stable.

    #118

    Michelle - July 3, 2009 - 13:23

    @andrewsuth: No, they won't be sortable because they aren't created with theme_table.

    Michelle

    #119

    Michelle - July 5, 2009 - 16:04

    Notes from IRC:

    [10:53] $output = theme('ctools_collapsible', $title, $content, $collapsed);
    [11:02] So it's still just a case of taking what's in theme_ctools_collapsible and re-organizing as you like. The handle is the clickable part, the content is the part that will go away. You'd want to provide a different toggle icon but that's doable with CSS easily enough.
    [11:02] The javascript adds the toggle icon so it won't appear if .js isn't available.

    Michelle

    #120

    niles - July 24, 2009 - 18:22

    sub

    #121

    apanag - August 25, 2009 - 14:09

    Hello,

    i am trying to create a patch for this feature. I tried ctools_collapsible, but that the theme function required a div element, but in the forum containers there is a table element.Thus it's not possible to use the ctools_collapsible unless it supports other html elements. So i think we have to write custom jquery code to support such a feature.

    #122

    Michelle - August 25, 2009 - 14:15

    I would prefer to use the CTools code since it's already a dependency. merlinofchaos is currently on vacation but I can talk to him about it after Drupalcon.

    Thanks for looking at it,

    Michelle

    #123

    apanag - August 25, 2009 - 14:22

    I believe too, that using CTools is a much better solution than writing custom code. But unless ctools_collapsible supports table elements is not possible to use this function.

    Thanks for your quick reply,
    apanag

    #124

    apanag - September 10, 2009 - 10:18

    Do we have any feedback on this?

    apanag

    #125

    merlinofchaos - September 10, 2009 - 14:16

    This commit should fix that: http://drupal.org/cvs?commit=261180

    #126

    apanag - September 10, 2009 - 19:27

    Yes i think its perfect for now.
    I think i ll be able to provide a patch for the collapsible blocks.

    Thank you merlinofchaos, for your work.

    #127

    Michelle - September 10, 2009 - 20:54

    Awesome, thanks!

    Michelle

    #128

    apanag - September 11, 2009 - 09:32

    @merlinofchaos
    I have some problems with the last version of the ctools.

    We have an html structure with a table:

    table
    thead
    tbody

    We want the thead to be the $handle area and tbody to be the $content area. If we use the theme function theme_ctools_collapsible_remembered, we will be having a div area inside a table and that's not valid.
    Finally the collapsible-div.js is looking always for div

    Drupal.behaviors.CToolsCollapsible = function(context) {
      $('div.ctools-collapsible-container:not(.ctools-collapsible-processed)', context)
        .each(Drupal.CTools.bindCollapsible)
        .addClass('ctools-collapsible-processed');
    }

    Is it possible to check only for the classes and if there are the correct classes to provide the functionality?
    For example if i manually wrote

    <table class="ctools-collapsible-remember ctools-collapsible-container">
    <thead class="ctools-collapsible-handle">
      <tr><th class="forum-icon"><span class="ctools-toggle"></span></th></tr>
    </thead>
    <tbody class="ctools-collapsible-content">
       <tr><td><td></tr>
    </tbody>

    #129

    apanag - September 19, 2009 - 09:02

    Hello guys,

    after working: http://drupal.org/node/558918 with merlinofchaos on ctools collapsed functionality, i created a patch to integrate collapsed areas into advanced_forum.module.
    This is my first attempt and i am waiting your feedback. There is still one issue left for display correctly the table.
    You have to use the latest dev release of ctools.

    Many kudos to merlinofchaos for his hard work.

    apanag

    PS:
    The patch is for naked style only.

    AttachmentSize
    advanced_forum-291084.patch 1.36 KB

    #130

    Michelle - September 19, 2009 - 22:00
    Status:active» needs review

    Thanks. I'll check this soon as I can. Going to be a very busy weekend and then I'm traveling so will likely be later next week.

    Michelle

    #131

    SamanthaV - October 18, 2009 - 16:17

    Any ETA on when this will be working. We have over 10 containers with approximately 15 forums in each. We seriously need collapsable containers to clean up the look and feel of advanced forums.
    Many Thanks
    Samantha

    #132

    Michelle - October 18, 2009 - 18:30

    @SamanthaV : Well, you can always test the patch. The more eyes on it the better. I don't have any personal need for this so it would be great if people who do have a need stepped up to help. :)

    Michelle

     
     

    Drupal is a registered trademark of Dries Buytaert.