Jump to content


Photo

Module: ModulesSectionCollapse


  • Please log in to reply
23 replies to this topic

#1 Soma

Soma

    Hero Member

  • Moderators
  • 5,041 posts
  • 3797

  • LocationSH, Switzerland

Posted 26 August 2011 - 07:31 PM

Hey, my first, just a little module to generate a TOC with links on top of modules page for overview and easing navigation.

Not sure if there's already something similar planed already for the Modules page in the core.
But none the less, it was fun to try out captain Hook :)

Just cleaned and checked this baby in: https://github.com/s...SectionCollapse

Attached Thumbnails

  • screen.png

@somartist | modules created | support me, flattr my work flattr.com


#2 Pete

Pete

    Forum Admin

  • Administrators
  • 2,380 posts
  • 1427

  • LocationChester, England

Posted 27 August 2011 - 04:10 AM

Nice work :)

It would be good if they were collapsible too ;)

#3 Soma

Soma

    Hero Member

  • Moderators
  • 5,041 posts
  • 3797

  • LocationSH, Switzerland

Posted 27 August 2011 - 06:41 AM

Thanks Pete. Yes, I also thought about this after I've done the TOC. :)

Here's a even more simple module that collapses the sections, and uses the sections titles to toggle the module table.

The new ModulesSectionCollapse Module is attached.

Edit: updated first post with github repo.

@somartist | modules created | support me, flattr my work flattr.com


#4 ryan

ryan

    Reiska

  • Administrators
  • 7,783 posts
  • 6531

  • LocationAtlanta, GA

Posted 27 August 2011 - 09:35 AM

Congrats on your first module and nice job!

Also wanted to mention another way you can get the JS into the document without having to modify the HTML. Instead of an str_replace, you can do this in your loadJS function:

$this->scripts->add($this->config->urls->ModulesTOC . "ModulesTOC.js");

The way you are doing it now is just fine too. But since PW already has a system for adding scripts in the admin theme, I figured I'd point out this option too.

Thanks,
Ryan




#5 Soma

Soma

    Hero Member

  • Moderators
  • 5,041 posts
  • 3797

  • LocationSH, Switzerland

Posted 27 August 2011 - 01:44 PM


Also wanted to mention another way you can get the JS into the document without having to modify the HTML. Instead of an str_replace, you can do this in your loadJS function:

$this->scripts->add($this->config->urls->ModulesTOC . "ModulesTOC.js");


Thanks Ryan, that's great. I thought there must be something like this, but couldn't figure it out yet (was too lazy).
Now I'm trying this and It doesn't work with addHookAfter Page::render:

Fatal error: Call to a member function add() on a non-object in /var/www/domains/zueblin.update.ch/site/modules/ModulesSectionCollapse/ModulesSectionCollapse.module on line 65
This error message was shown because the site is in DEBUG mode.

SO I thought the hook must be different but can't get it work. addHookAfter Page::loaded etc... Can you give me a hint? Thanks.

@somartist | modules created | support me, flattr my work flattr.com


#6 ryan

ryan

    Reiska

  • Administrators
  • 7,783 posts
  • 6531

  • LocationAtlanta, GA

Posted 27 August 2011 - 01:55 PM

Sorry Soma, typo--my mistake, it should be $this->config->scripts not $this->scripts

#7 Soma

Soma

    Hero Member

  • Moderators
  • 5,041 posts
  • 3797

  • LocationSH, Switzerland

Posted 27 August 2011 - 02:08 PM

Still, the add error is gone but script isn't added. Any Ideas?

<?php 
public function init() {
		$this->addHookAfter('Page::render', $this, 'loadJS'); 
	}


	public function loadJS($event) {
		if($this->process == 'ProcessModule')
			$this->config->scripts->add($this->config->urls->ModulesSectionCollapse . "ModulesSectionCollapse.js");
			
	}

@somartist | modules created | support me, flattr my work flattr.com


#8 Pete

Pete

    Forum Admin

  • Administrators
  • 2,380 posts
  • 1427

  • LocationChester, England

Posted 27 August 2011 - 02:16 PM

Maybe add it before render?

#9 Soma

Soma

    Hero Member

  • Moderators
  • 5,041 posts
  • 3797

  • LocationSH, Switzerland

Posted 27 August 2011 - 02:21 PM

No luck. :/

@somartist | modules created | support me, flattr my work flattr.com


#10 ryan

ryan

    Reiska

  • Administrators
  • 7,783 posts
  • 6531

  • LocationAtlanta, GA

Posted 27 August 2011 - 02:25 PM

Yes the before render is I think what you need. That should work. Always hard for me to tell the right things when away from the computer (just on mobile today)

#11 Soma

Soma

    Hero Member

  • Moderators
  • 5,041 posts
  • 3797

  • LocationSH, Switzerland

Posted 27 August 2011 - 02:29 PM

I changed to addHookBefore('Page::render',..

It still doesn't load the script.

@somartist | modules created | support me, flattr my work flattr.com


#12 ryan

ryan

    Reiska

  • Administrators
  • 7,783 posts
  • 6531

  • LocationAtlanta, GA

Posted 27 August 2011 - 03:00 PM

Not sure why. Double check all filenames are where. I will try when I get back to computer

#13 Soma

Soma

    Hero Member

  • Moderators
  • 5,041 posts
  • 3797

  • LocationSH, Switzerland

Posted 27 August 2011 - 03:31 PM

Thanks for the help, but can't get it to work... checked files and tried all different variations.

@somartist | modules created | support me, flattr my work flattr.com


#14 apeisa

apeisa

    Hero Member

  • Moderators
  • 3,152 posts
  • 1697

  • LocationVihti, Finland

Posted 27 August 2011 - 03:57 PM

$this->addHookAfter('Process::execute', $this, 'loadJS');


#15 Soma

Soma

    Hero Member

  • Moderators
  • 5,041 posts
  • 3797

  • LocationSH, Switzerland

Posted 27 August 2011 - 03:59 PM

$this->addHookAfter('Process::execute', $this, 'loadJS');


Works! Thanks, you're my hero! :)

@somartist | modules created | support me, flattr my work flattr.com


#16 apeisa

apeisa

    Hero Member

  • Moderators
  • 3,152 posts
  • 1697

  • LocationVihti, Finland

Posted 27 August 2011 - 04:04 PM

No worries, glad you got it working.

That is nice little module and got me thinking. Modules page is not only place where lists get very long and would benefit from some more js love. I have used Datatables a lot and I think it would be perfect on many lists that pw has. It has nice filter search, pagination, sorting, it is fast and easy to use. As a little bonus it supports themeroller. Also possible to use with huge datasets with ajax.

http://www.datatables.net/ - just that you guys can take a look - don't wanna capture Soma's module topic here :)

#17 Soma

Soma

    Hero Member

  • Moderators
  • 5,041 posts
  • 3797

  • LocationSH, Switzerland

Posted 27 August 2011 - 05:01 PM

Here's a new version of the modules section collapse module. Added count and +-

Hope it's useful for someone.

Edit: updated first post with github repo.

@somartist | modules created | support me, flattr my work flattr.com


#18 Soma

Soma

    Hero Member

  • Moderators
  • 5,041 posts
  • 3797

  • LocationSH, Switzerland

Posted 27 August 2011 - 05:08 PM

That is nice little module and got me thinking. Modules page is not only place where lists get very long and would benefit from some more js love. I have used Datatables a lot and I think it would be perfect on many lists that pw has. It has nice filter search, pagination, sorting, it is fast and easy to use. As a little bonus it supports themeroller. Also possible to use with huge datasets with ajax.


Actually that's a very nice and simple to use plugin I also used (after trying some datatable plugins) in some codeigniter projects, with ajax and themeroller styling, especially like the cookie state save option and sortable, filterable. It was very nice as my apps also uses jquery ui. Would be nice to have such a feature for very large lists. Wasn't this already discussed somewhere?

@somartist | modules created | support me, flattr my work flattr.com


#19 apeisa

apeisa

    Hero Member

  • Moderators
  • 3,152 posts
  • 1697

  • LocationVihti, Finland

Posted 27 August 2011 - 05:18 PM

Wasn't this already discussed somewhere?


Probably, but can't remember. I have used datatables many times, and I have only good to say about that plugin. Rock solid stuff it is!


Here's a new version of the modules section collapse module. Added count and +-


Nice update!

#20 Soma

Soma

    Hero Member

  • Moderators
  • 5,041 posts
  • 3797

  • LocationSH, Switzerland

Posted 20 September 2011 - 02:46 PM

Just cleaned and checked in on github. Updated first post too.

https://github.com/s...SectionCollapse
Makes things alot easier. Thanks

@somartist | modules created | support me, flattr my work flattr.com





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users