Recent Topics

[2.4.1] Collapsable Categories plugin

Started by on Mar 27, 2008 – Contents updated: Mar 27, 2008

Mar 27, 2008 18:51    

This is an old hack that uses the mktree javascript to generate a collapsable Catagories list. This is an image "that says more than a thousand words":

http://www.blog.hemminga.net/media/blogs/plugins//cat.png

You find the description in the [url=http://forums.b2evolution.net/viewtopic.php?t=4884]forums[/url].

As reported in another post in the [url=http://forums.b2evolution.net/viewtopic.php?t=13270]forums[/url] the collapsable categories hack doesn't work in B2evo 2.4. This is because the categories are now generated by the core plugin. The settings for the widget are moved to the Dashboard.

Luckily this opens the possibility to make a plugin to genererate the code for the retractable lists. With the invaluable help from [url=http://innervisions.org.uk]¥åßßå[/url] we managed to get rid of the hack and control the settings in the Dashboard. This means you no longer have to change files,

To use the plugin, first download [url=http://www.blog.hemminga.net/media/blogs/plugins/collapsable_categories_plugin.zip]collapsable_categories_plugin.zip[/url] unzip and install as you would with any other plugin. To activate, visit the "Categories list" widget in Dashboard -> Blog settings -> CHOOSE BLOG -> Widgets and add "collapse_me" without the quotes in the box that says "CSS Class". See this image:

http://www.blog.hemminga.net/media/blogs/plugins//WidgetSettings.png

This way you control which widget will be collapsable. The use is not limited to the Category widget, any widget that has nested links can be made collapsable by putting the magic quote "collapse_me" in the CSS Style box.

Have fun

Mar 27, 2008 23:34

great plugin Afwas, will do good for many purposes, may come handy at any time.. thank you very much B)

edit: tested right away, working great

Mar 28, 2008 07:21

Thanks sam2kb,

Confirmed in Opera 9.25 on Ubuntu 8.04

Mar 28, 2008 11:56

I don't and haven't used this enhancement, but way back in the day the same problem - foodles of [+] boxes - happened and I'm pretty sure it was overcome. Sadly, I've no info on *how* to overcome it. Searching diligently might be your friend?

Mar 29, 2008 06:39

i guess it doesnt work when you switch your skin.. i have made a few try, when i switch back to the skin when i installed the plugin; works again..

can anyone else try switching skins after installing this plugin and report back pls ?_?

Mar 29, 2008 19:57

it wasnt about the plugin... working good now..thank you again..

==========================================
just replaced

	'block_start' => '<div class="$wi_class$ bSideItem">',
	    'block_end' => '</div>',


with this

	'block_start' => '<li class="$wi_class$ bSideItem">',
	    'block_end' => '</li>',

Apr 05, 2008 10:50

it is likely to be about your skin.. probably sidebar.. may be u should tell us which skin you are using unless it is a custom one or post your sidebar.inc.php

Apr 05, 2008 13:13

Afwas wrote:

cslepage, how come your widgets start with a <div> and not with a <li>? Did you hardcode the widgets in the sidebar? ...

For the sidebar container, only evopress and evocamp (of the package skins) use LI for block_start. All others use DIV.

Apr 05, 2008 13:22

Thanks EdB,

I hadn't noticed that one yet. ;) I don't think I am happy with it either :|

Apr 05, 2008 14:05

My skin is b2evo_ru, though I have modified it, but I certainly didn't hardcode these widgets into the sidebar.

I uploaded the new version you posted just for me, and I don't yet see a difference.

Could this be what tilqicom saw on March 29? And if so, where do I make the change they made?

Apr 05, 2008 14:09

Afwas wrote:

cslepage, how come your widgets start with a <div> and not with a <li>? Did you hardcode the widgets in the sidebar?
Good luck

Looking in sidebar.inc.php, that's the way the author wrote that file.

Apr 05, 2008 15:01

Hi cslepage,

The new version seems to cure your problem on my testblog. In your blog I cannot see the plugin loaded correctly. If it were loaded correctly you would find this in the header:

<!-- START Stylesheet and JavaScript file for expandable Categories -->
<link rel="stylesheet" href="/plugins/collapsable_categories_plugin/mktree.css" type="text/css" />
<script src="/plugins/collapsable_categories_plugin/mktree.js" type="text/JavaScript"></script>
<!-- END Stylesheet and JavaScript file for expandable Categories -->

So do check the plugin settings, reload the plugin and try Tools -> Misc-> Delete prerendered item cache.

Good luck

Apr 05, 2008 15:05

The new version seems to cure your problem

It works for me too, I was going to post the fix when I saw your edited post ;)

Apr 05, 2008 15:26

Afwas wrote:

Hi cslepage,

The new version seems to cure your problem on my testblog. In your blog I cannot see the plugin loaded correctly. If it were loaded correctly you would find this in the header:

<!-- START Stylesheet and JavaScript file for expandable Categories -->
<link rel="stylesheet" href="/plugins/collapsable_categories_plugin/mktree.css" type="text/css" />
<script src="/plugins/collapsable_categories_plugin/mktree.js" type="text/JavaScript"></script>
<!-- END Stylesheet and JavaScript file for expandable Categories -->

So do check the plugin settings, reload the plugin and try Tools -> Misc-> Delete prerendered item cache.

Good luck

Looks like it is working for the linkblog, thanks!

Apr 05, 2008 15:34

Yes, working great now.

have fun

May 23, 2008 13:34

Is there any way to display collapsable categories opened by default ?

May 25, 2008 01:43

this is really weird for me, as i ve previously got this category plugin working in my other website perfectly..

i am getting this view:

http://i30.tinypic.com/2cz9ffn.jpg

I thought it might be because of sidebar li properties however whichever skin i use the problem persists, this is so strange, i wonder what might cause this to happen

May 25, 2008 12:52

@tilqicom,
You have a curious problem, caused by gathering categories from different blogs. Only the first blog is collapsing. The sturcture is like:
<li>
<ul>
<li>
<li>
</ul>
<ul>
...
</li>
This second <ul> is caused by the second blog and the widget is trained to act on the first <ul> only.

@slamp:
I noticed the same problems on evoskin. This is caused by the original style applied to the list. I haven't found a way yet to get rid of this style before the widget acts on it.

May 25, 2008 13:23

There is a way this can be worked out, but it would require people to edit a file to make it happen.

Root cause is that the plugins affect the document head way early in the process, meaning any styles applied get over-ridden by styles that come later. Specifically, and only looking at the bits that matter, _html_header.inc.php has this:

	<?php $Plugins->trigger_event( 'SkinBeginHtmlHead' ); ?>
	...
	<link rel="stylesheet" href="style.css" type="text/css" />
	<?php include_headlines() /* Add javascript and css files included by plugins and skin */ ?>
	<?php
		$Blog->disp( 'blog_css', 'raw');
		$Blog->disp( 'user_css', 'raw');
	?>

IF a user were to edit that file in their skins/ or skins/yourskin/ folder to the following bit then the plugin could supply style instructions that would over-ride the default instructions in the skin.

	<link rel="stylesheet" href="style.css" type="text/css" />
	<?php $Plugins->trigger_event( 'SkinBeginHtmlHead' ); ?>
	<?php include_headlines() /* Add javascript and css files included by plugins and skin */ ?>
	<?php
		$Blog->disp( 'blog_css', 'raw');
		$Blog->disp( 'user_css', 'raw');
	?>

In a perfect world, the file would be a bit more intelligent than just this, but for the purpose of this thread I believe this would allow the plugin to properly work with the nested UL situation.

I think. That's my problem most of the time yah? Like for example I thought if I took a week off for Memorial Day weekend I could maybe do some flying but it turns out this weekend decided to be super-rainy and ultra-windy. :'(

May 25, 2008 13:41

Wait a minute - stop the presses!

It looks to me like the add_headline() function can do the job, though I don't know how it gets used. I do not know of any plugins using that function, but the evopress and nifty_corners skins are using it to add bits via the include_headlines() function, so maybe it is possible for an intelligent* person to make a plugin take advantage of that feature?

* "intelligent" means someone like Afwas or sam2kb or even the script kiddie known as Yabba - not me.

May 25, 2008 14:49

Thanks EdB,

You're right. I found that one already. It's nephews are require_js() ans require_css(), both are added at the bottom of the <head> section.
The add_headline() is for plain code as in:

add_headline( '<script type="text/javascript">
    // your code goes here
</script>' );


Here are some more examples:

require_js( '#jquery#' );
require_js( '/plugins/foo/bar.js', true ); // true makes relative to baseurl,
                                           // default false searches for js in /rsc/js/.
require_css( 'basic.css' ); // false -> searces in /rsc/css/
$foo = '<style type="text/css">
  // your style
</style>'
add_headline( $foo );

This may solve some of the troubles. However the evopress skins uses custom bullets. In the added style for the new plugin I have

list-style: none;


to reset the bullets, but that doesn't work on the custom bullets from the evopress skin. No doubt the problem with the evocamp skin is similar. It does work on the 'custom' skin however.

So I did look at it from the point you mentioned in the new plugin. I haven't found a 'this solves all problems' answer yet.

Oct 02, 2008 16:35

I already tried this but nothing really happens. I'm using evocamp please help.

Oct 04, 2008 18:26

I will look at it this weekend.

Feb 09, 2009 23:24

Hi Guys,

I was wondering if you can have a look at my testskin and help me out with an issue. I've got the expanding categories working correctly - but some reason it only works on the first blog. Once the second blog list starts it reverts back to having all categories shown.

Thanks for the help,
Akgbob

Here's the link: http://www.leenaeats.com/blog/index.php?tempskin=LE2

Feb 09, 2009 23:29

Hi akgbob. I'm seeing it do the collapse thing just fine on both the first and additional pages of your blog posts.

Oh and I totally dig on that skin!

Firefox 2.whatever, enabled javascript cuz I had to.

Feb 09, 2009 23:41

Thanks for the compliment - its a skin a made awhile back - pretty but the codes a bit of a mess. Finally getting around to cleaning it up and updating for the newer perks of 2.x

Let me clarify my statement. If you look at the categories its broken out by "Leena Eats This Blog" and "Chicken n' Waffles". Some reason the expansion works on the Leena Eats categories, but it didn't work on the CNW categories. Here's what I'm looking at:

http://www.leenaeats.com/Images/example.jpg

Thanks again for the quick reply!

Feb 09, 2009 23:52

I should rewrite that bloody thing. You have no idea how much I've struggled with it to get it where it's now. I'll have a look at the end of the week or early next week. Somebody remind me please.
Can you please check if a second install of the plugin helps here?

Good luck

Feb 09, 2009 23:53

No worries - thanks for all the work you've already put into it!


Form is loading...

Secure CMS – This forum is powered by b2evolution CMS, a complete engine for your website.