Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Links Table Definition

Quote Reply
Links Table Definition
Just a newbie with a question that's probably simple.

I added some fields to the links table definition. They all came out at the bottom instead of the order I would like them to be in.

How do I change the position of these items?

KittyMother




Quote Reply
Re: Links Table Definition In reply to
you can't.

you'd have to drop the table, and re-create it with the fields in the order you wanted.

This only matters in the "admin" area, everything else uses templates to control what the output looks like.


http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Links Table Definition In reply to
i made a mod to do this..

i was tired of having the important fields at the bottom.. hold on a second..

Jerry Su
Quote Reply
Re: Links Table Definition In reply to
start with DBSQL.pm..

find....

Code:
$self->{'db_is_indexed'} = 0;
after.. add

Code:
$self->{'db_order'} = {};
now go down a few lines and find this..

Code:
$self->{'db_indexed'}{$_} = $db_def{$_}[7];
add this under..

Code:
$self->{'db_order'}{$_} = $db_def{$_}[8];
now go to sub build_html_record..

replace..

Code:
foreach my $field (@{$self->{'db_cols'}}) {
with..

Code:
my %columns = %{$self->{'db_order'}};
foreach my $field (sort { $columns{$a} <=> $columns{$b} } keys %columns) {
now do the same thing in sub build_html_record_form..

ok.. now on to editor.cgi..

find..

Code:
elsif ($show eq 'delete') {
a few lines down find..

Code:
foreach my $column (@{$db->{'db_cols'}}) {
replace with..

Code:
my %columns = %{$db->{'db_order'}};
foreach my $column (sort { $columns{$a} <=> $columns{$b} } keys %columns) {
same thing a few lines under

Code:
elsif ($show eq 'update') {
now go to sub add_field

replace
Code:
$db->{db_def}{$column} = [ $last_f, $type, $fmax, $max, $null, $def, $val, $index ];
with

Code:
my @order = sort { $b <=> $a } values %{$db->{'db_order'}};
my $last_o = $order[0] 1;
$db->{db_def}{$column} = [ $last_f, $type, $fmax, $max, $null, $def, $val, $index, $last_o ];
now go to sub update_fields

add

Code:
/^order-(. )$/ and ($order{$1} = $in->param($_)) and next;
before

Code:
/^form-(. )$/ and ($form{$1} = $in->param($_)) and next;
add

Code:
, %order
into the my list at top.. ie: my (%form, %max, %null, Þfault, %validate, %indexed, %order, @update_fields);

replace

Code:
$db->{db_def}{$field} = [$org->[0], $org->[1], $form{$field}, $max{$field}, $null{$field}, $default{$field}, $validate{$field}, $indexed{$field}];
with

Code:
$db->{db_def}{$field} = [$org->[0], $org->[1], $form{$field}, $max{$field}, $null{$field}, $default{$field}, $validate{$field}, $indexed{$field}, $order{$field}];
ok.. modding done..

now when you look at your admin.. the order is going to be jumbled.. basically.. you have to go into editor for each database and set the orders.. i suggest making ID = 0.. and then start from whatever.. 1 2 3 4 5 6 7 etc..

after you finish (may take awhile..) it'll be in the order.. any newly added fields will automatically be placed at the end.. but you can change the order..

Jerry Su