Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Change order of fields in Admin Link add template

Quote Reply
Change order of fields in Admin Link add template
http://www.gossamer-threads.com/perl/gforum/gforum.cgi?post=212875#212875Hi I was wondering if it is possible to change the order of fields that appear in the template for the admin to add a link.

There are "position" numbers next to each and I would like for example to move Description at position "7" to position "4" and also move another custom field I have added to position "2".

Does anybody know how to change this ?

John

Edit : just found this link I missed in previous search :
http://www.gossamer-threads.com/...i?post=212875#212875
Rant : I can't believe this hasn't been changed to make things easier for editors to have mandatory fields first then optional ones that follow and this may vary depending on the web site. Having a position order system for the fields would allow for this instead of just relying on database order !
Significant Media

Last edited by:

Jag: Jan 4, 2005, 7:03 PM
Quote Reply
Re: [Jag] Change order of fields in Admin Link add template In reply to
I think the problem here is that pos=> was potentially designed to allow a reordering of the display of autogenerated fields, but if you look at some of the code, it seems that array calls may use the pos field to understand the description of the database -- eg: knowing what data to put where. Changing the pos=> value might affect that (while not affecting hash-type calls, where column=>data pairs are specifically named, and order isn't important).

To do this right, would mean adding a field/method to the Table.pm, display_pos which would initially be set in the 'create' command, or default to the pos (physical/logical) position.

To use it, rather than calling Table->cols you'd call Table->display_cols and you'd get the data back using display_pos not pos.

It shouldn't be hard to add in (all the code is written), but means editing/changing some core modules.

Preserving the field order during a resync would be more difficult, but might be able to be done using the configuration file.

Or, since almost all file commands seem to fail on Unix systems if the file doesn't exist, first reading the .def file to preserve the display_pos field, and then inserting it into the data retrieved might work.

If Alex can confirm that the pos=> field is *nothing* to links, except a display order, it would be fairly trivial to write a position editor, and preserve field orders.

The only trick would be to remember to "Update field positions" after a resync, unless there is a resync hook.


PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Change order of fields in Admin Link add template In reply to
Hi Pugdog,

I think what I'm going to say will show how little I know about databases and maybe perl but here goes... Wink

I don't actually understand why in this specific case of a form being used to populate fields in a database why the form cannot be created by an intermediary list that says data field 1 displayed in first position or hidden, data field 7 displayed in second position etc. rather than using field position in the database. It just feels to me to be to close to what you would have if there wasn't a GUI interface for adding data to the database and having worked on ERP systems it brings back bad memories Frown.

Hopefully Alex or a GT member of staff can bring some good news on your more relevant questions Smile

John
Significant Media
Quote Reply
Re: [Jag] Change order of fields in Admin Link add template In reply to
Hi John,

Just for info - this is the post that I used and it worked well for me (other people seem to have had problems and I recommend backing up your database first):
http://www.gossamer-threads.com/...i?post=261402#261402
Quote Reply
Re: [Jag] Change order of fields in Admin Link add template In reply to
I've made this in admin/defs/lsql_links.def
and reorder the fields with the pos field

'pos' => '1',

BTW: You can't use resync database after that or you will loose any changes

Best regards from
Bremen/Germany

Lothar

Last edited by:

eljot: Jan 12, 2005, 5:56 AM
Quote Reply
Re: [afinlr] Change order of fields in Admin Link add template In reply to
Hi

Thanks Laura and eljot for your feedback; it certainly sounds a bit risky having to play about with the database like that just for presentation requirements !

So if I have understood the clockwork properly, I change the column position in mySQLman and then get LinksSQL to sync with the new order so that it doesn't get mixed up with the old order when updating the database ?

However the syntax here bewilders me :

Quote:
1. Move the columns via MySQLMan or SQL:

ALTER TABLE table CHANGE COLUMN col same type info AFTER other_col

2. Then run resync table from the admin to update the .def file.

what would be an actual example here ? I'm not quite sure what the last two parts in red are supposed to be ! Blush

I suppose the first red "table" is the name of the table but the rest, I don't get it.

Thanks, John
Significant Media
Quote Reply
Re: [Jag] Change order of fields in Admin Link add template In reply to
In Reply To:
So if I have understood the clockwork properly, I change the column position in mySQLman and then get LinksSQL to sync with the new order so that it doesn't get mixed up with the old order when updating the database ?[/quote]
Exactly

Here's an example:

ALTER TABLE lsql_Links CHANGE Description Description TEXT AFTER Add_Date

Note that you have to put the correct type of column and other information after the name of the column that you want to use - have a look at the properties of the table in mysql man to see what type of column it is.

Here's a relevant thread:
http://www.gossamer-threads.com/...i?post=264466#264466

Last edited by:

afinlr: Jan 12, 2005, 7:24 AM
Quote Reply
Re: [afinlr] Change order of fields in Admin Link add template In reply to
Thanks alot Laura, I'll try it out.

BTW Silly question Blush but why is Description down twice in your statement ?

John
Significant Media
Quote Reply
Re: [Jag] Change order of fields in Admin Link add template In reply to
I think the first one is telling mysql which column to change and the next one is telling it what you want the new column to be called. I'm sure there must be an explanation of this somewhere on the mysql site.