Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-05-19 03:46:36

Ruhh
Member
From: dakota dunes
Registered: 2008-01-20
Posts: 305

must have hack?

I want to create myself a small admin-side plugin for putting the forms into groups and each group would have a header in which I can click to toggle on/off. But before I look into the source, does it require me to go in one of the textpattern files and hack in order to make this work?


<txp:Ruhh />

Offline

#2 2008-05-19 03:48:13

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: must have hack?

You could use a plugin and:

  • replace the necessary functions
  • use JavaScript (jQuery)

Offline

#3 2008-05-19 03:50:29

Ruhh
Member
From: dakota dunes
Registered: 2008-01-20
Posts: 305

Re: must have hack?

What plugin? I have the script needed to toggle on/off but I am not 100% certain on how I can put each type of forms into groups.

Last edited by Ruhh (2008-05-19 03:50:59)


<txp:Ruhh />

Offline

#4 2008-05-19 04:24:24

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: must have hack?

Write your own! :) You don’t need to hack anything.

For the JavaScript, you could loop through the forms table and create an array for each form-type, adding forms that match to the appropriate arrays. After that, it’s simple HTML insertion.

Offline

#5 2008-05-19 05:00:15

Ruhh
Member
From: dakota dunes
Registered: 2008-01-20
Posts: 305

Re: must have hack?

You mean the forms table in the Presentation tab or in the MySQL database?


<txp:Ruhh />

Offline

#6 2008-05-19 05:14:26

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: must have hack?

Well you actually have a few options –

  1. With PHP (and an output buffer) you could grab the forms from the database and easily generate an organized list. Then run str_replace to replace the forms HTML table with your organized output.
  2. With JS-only, you would grab the forms from the HTML table and store them as arrays.

Last edited by jm (2008-05-19 05:16:40)

Offline

#7 2008-05-19 06:23:51

Ruhh
Member
From: dakota dunes
Registered: 2008-01-20
Posts: 305

Re: must have hack?

I give up. Anyone wanna make this kind of plugin?


<txp:Ruhh />

Offline

#8 2008-05-19 07:36:30

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,727
Website

Re: must have hack?

I give up!

Not so fast :o) Here’s how I’d go about it if I had a little more time on my hands: take a look at lam_accordion_section which does what you want but for the section tab using jquery (it’s short, only 15-20 lines of code). Look at the source code of the “section” tab to see how it does what it does (jquery is quite easy to follow). Then look at the source code of the “forms” tab and adapt the script accordingly. The script is short so it shouldn’t be too hard. And, of course share when you’re done :o)

Last edited by jakob (2008-05-19 07:37:12)


TXP Builders – finely-crafted code, design and txp

Online

#9 2008-05-19 15:15:14

Ruhh
Member
From: dakota dunes
Registered: 2008-01-20
Posts: 305

Re: must have hack?

Yeah. I really don’t get it. I’m not trying to hide all of the forms. Just groups of them by type. For example, a group of article forms and a group of misc forms and so on.

Last edited by Ruhh (2008-05-19 15:19:57)


<txp:Ruhh />

Offline

#10 2008-05-19 15:58:13

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: must have hack?

I have a hack which will do exactly what you ask above but no “accordian”. You will need to edit the /textpattern/include/txp_form.php file. Look for the “function form_list” around line 32 and replace it completely with this but do a backup first please:-

	function form_list($curname)
	{
		global $step,$essential_forms;
		$out[] = startTable('list');
		$out[] = tr(tda(sLink('form','form_create',gTxt('create_new_form')),' colspan="3" style="height:30px"'));
		$methods = array('delete'=>gTxt('delete'));
		$rs = safe_rows_start("*", "txp_form", "1 order by type asc, name asc");
		$oldtype = '';
		if ($rs) {
			while ($a = nextRow($rs)){
				extract($a);
				if ($type != $oldtype)
					$out[] = assHead($type,'');
					$editlink = ($curname!=$name)
					?	eLink('form','form_edit','name',$name,$name)
					:	htmlspecialchars($name);
					$modbox = (!in_array($name, $essential_forms))
					?	'<input type="checkbox" name="selected_forms[]" value="'.$name.'" />'
					: '<input type="checkbox" disabled="disabled" />';
				$out[] = tr(td($editlink).td($modbox));
				$oldtype = $type;
			}
			$out[] = endTable();
			$out[] = eInput('form').sInput('form_multi_edit');
			$out[] = graf(selectInput('edit_method',$methods,'',1).sp.gTxt('selected').sp.
				fInput('submit','form_multi_edit',gTxt('go'),'smallerbox')
				, ' align="right"');
			return form( join('',$out),'',"verify('".gTxt('are_you_sure')."')" );
		}
	}

If I remember correctly it was originally Guiguibonbon’s code.

Last edited by thebombsite (2008-05-19 16:04:12)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#11 2008-05-19 16:10:52

Ruhh
Member
From: dakota dunes
Registered: 2008-01-20
Posts: 305

Re: must have hack?

Meh, I was hoping no hack. But I will see what I can do with PHP or the other way, JS.


<txp:Ruhh />

Offline

#12 2008-05-19 16:38:35

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: must have hack?

<input type="thx_boxes" disabled="0" receiver="thebombsite,guiguibonbon asc" />


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB