Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Column adding? huh?? Cat needs advice

Quote Reply
Column adding? huh?? Cat needs advice
ok boys need you to tell me a little more about column adding - that isnt the manual.

ok when i add a column to links table there are a few fields i dont understand fully;

Column Values
(Only for ENUM types)

Form Names
(Stored in Database)
Only for checkbox, multi-select or radio forms.

Form Values
(Displayed on Form)
Only for checkbox, multi-select or radio forms.

Say i want a location column i dont really understand where i would put the countries? Is it in Column values, form names or form values? or all of them?

Also what would my syntax be in the include_form.html ?? Would i then need to type the countries out again in a select form object?

how and where are the form names, form values and column values used? I think i understand but it doesnt seem to work so i need someone to tell me! Smile

Thanks

Cat xx

http://www.catlovette.com
Quote Reply
Re: [catlovette] Column adding? huh?? Cat needs advice In reply to
I wondered what a catlovette was.... I see it's you ;)

Anyway, the question you ask is somewhat complex.

Entering the fields and such will make them show up as drop down lists in the admin/editors areas, but you still need to hard-code the dropdown box in your add/modify forms.

Depending on what you want to do, it might be better to chose another means for what you are doing, such as using tables of data, include blocks of code, etc.

Embedding it in the MySQL columns is not the best except for short simple things.

For a list of countries, you'd want to set up a varchar field, and then in your include_form for add/modify you'd want to create the drop down list in html.

Alternatively, you could create a table with two columns ID/Country and then use a short global to create the HTML for you on the fly. The add/modify system is dynamic even on static sites.

I would go with that last way.

You could then edit the table to make changes which are then reflected in your whole system. You could then expand the table to include fields that modify or alter what features or offers you have on a country-by-country basis. You could disallow certain countries, or force certain countries to mail you cash.

With a states table, you could do the same thing.

By keying a user to a state, you could limit what that user could access -- such as no mail. Not perfect, but it does show compliance with applicable laws and attempted avoidance of other issues.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Column adding? huh?? Cat needs advice In reply to
I wondered what a PUGDOG was.... Wink thanks for that! I couldnt find anything else on it! Surley alot of people will need large selects!

Thanks! ok i see your point here. I'll have a go at creating a country table!

Could you give me an idea what the global would look like?

Also what would the syntax look like to bring up the country select in html?

Thanks

Cat xxxTongue
Quote Reply
Re: [catlovette] Column adding? huh?? Cat needs advice In reply to
The following link contains an alternative, working solution:

http://www.gossamer-threads.com/...rum.cgi?post=211270;

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Column adding? huh?? Cat needs advice In reply to
ok, not quite sure what to do now. As far as i see it there are a few options;

1. I can create my own table of columns i want to have as selects. (im not sure how i call this table in html etc yet though)

2. Use pagebuilder. - Will this help me create a complex add form? with selects and radio buttons etc or will i still have to create complex globels?

3. I can use a global like this;
Code:
sub { my $element_name = 'Pais'; # set the control's name here
my $default_value = 'xyzty'; # and the default country you'd like to use
my @list = qw(
Albania
Alemania
Andorra
Angola
Anguilla
Antártida
Antigua_y_Barbuda
Antillas_Neerlandesas
Arabia_Saudí
Argelia
Argentina
Aruba
Australia
Austria
Azerbaiyán
Azores
Bahamas
Bahrein
Bangladesh
Barbados
Bélgica
Belice
Benín
Bermudas
Bielorrusia
Bolivia
Bonaire
Bosnia-Herzegovina
Botswana
Brasil
Brunei
Bulgaria
Burkina_Faso
Burundi
Bután
Cabo_Verde
Camboya
Camerún
Canadá
Chad
Chile
China
Chipre
Ciudad_del_Vaticano
Colombia
Commonwealth_de_las_Marianas_del_Norte
Congo
Corea_del_Sur
Costa_de_Marfil
Costa_Rica
Croacia
Curaçao
Dinamarca
Djibouti
Dominica
Ecuador
Egipto
El_Salvador
Emiratos_Árabes_Unidos
Eritrea
Escocia
Eslovaquia
Eslovenia
España
Estados_Federados_de_Micronesia
Estados_Unidos
Estonia
Etiopía
Fiji
Filipinas
Finlandia
Francia
Gabón
Gales
Gambia
Georgia
Ghana
Gibraltar
Granada
Grecia
Groenlandia
Guadalupe
Guam
Guatemala
Guayana_Francesa
Guinea
Guinea_Bissau
Guinea_Ecuatorial
Guyana
Haití
Holanda
Honduras
Hong_Kong
Hungría
India
Indonesia
Inglaterra
Irak
Irán
Irlanda
Irlanda_del_Norte
Islandia
Islas_Caimán
Islas_Canarías
Islas_Cook
Islas_del_Canal
Islas_Feroe
Islas_Marshall
Islas_Norfolk
Islas_Salomón
Islas_Turks_y_Caicos
Islas_Vírgenes_Americanas
Islas_Vírgenes_Británicas
Israel
Italia
Jamaica
Japón
Jordania
Kazajstán
Kenia
Kirguizistán
Kiribati
Kosrae
Kuwait
Laos
Lesoto
Letonia
Líbano
Liberia
Libia
Liechtenstein
Lituania
Luxemburgo
Macao
Macedonia
Madagascar
Madeira
Malasia
Malawi
Maldivas
Malí
Malta
Marruecos
Martinica
Mauricio
Mauritania
México
Moldovia
Mónaco
Montserrat
Mozambique
Myanmar
Namibia
Nepal
Nicaragua
Níger
Nigeria
Noruega
Nueva_Caledonia
Nueva_Zelanda
Omán
Paises_Bajos
Pakistán
Palau
Panamá
Papúa-Nueva_Guinea
Paraguay
Perú
Polinesia_Francesa
Polonia
Ponatpe
Portugal
Puerto_Rico
Qatar
Reino_Unido
República_Centroafricana
República_Checa
República_Democrática_del_Congo
República_Dominicana
Reunión
Rota
Ruanda
Rumania
Rusia
Saba
Saipan
Samoa_Americana
Senegal
Seychelles
Sierra_Leona
Singapur
Siria
Sri_Lanka
St._Barthelemy
St._Christopher
St._Croix
St._Eustatius
St._John
St._Kitts_y_Nevis
St._Lucia
St._Maarten
St._Martin
St._Thomas
St._Vincente_y_las_Granadinas
Suazilandia
Sudáfrica
Sudán
Suecia
Suiza
Surinam
Tahití
Tailandia
Taiwán
Tanzania
Tayikistán
Tinian
Togo
Tonga
Tortola
Trinidad_y_Tobago
Truk
Tunicia
Turquía
Tuvalu
Ucrania
Uganda
Union_Island
Uruguay
Uzbekistán
Vanuatu
Venezuela
Vietnam
Virgen_Gorda
Wake_Island
Wallis_y_Futuna_Islands
Western_Samoa
Yap
Yemen
Zambia
Zimbabwe
);
grep { tr,_, ,;0 } @list;
# add your countries here. One per line is ok. my $return = q|<select class="pais" name="Pais"><option value="">---</option>|; my $tags = shift || {};
my $selected = $tags->{$element_name} || $default_value;
$selected = { map {($_=>1)} ref $selected ? @$selected : $selected };



foreach my $country ( @list ) {
my $ischosen = $selected->{$country} ? " selected" : "";
$return .= qq|<option$ischosen>$country</option>|;
}



$return .= q|</select>|;

return $return;
}

Is pagebuilder the easiest way? if it is then thats what i'll use?
Cat xx
Quote Reply
Re: [catlovette] Column adding? huh?? Cat needs advice In reply to
What I see you asking has nothing to do with building pages, but rather manipulation of data, and where that data is stored.

Usually, you would create linked fields/tables to do this. When you call a state_select box, you would populate from the States table. Only data/elements in that table would be available to select, or you would also have an option to add a new select element. The purpose is to both limit the choices, and to ensure data integrety (no typos).

To bring that data into the htm., is where you'd use the global. The global would just make a simple call to the table, and create a select box element, just like the category select box does in the add/modify form.

When you want to display the record, you would simply list the category element, or you would create a new dropdown/select list with that element selected.

For true data normalization, you'd use the key field, and every time the record was called, you'd join the table at the key field. This is probably over kill for this application, if all you want to do is populate a record, make it easy for the user to select it, and limit the selection.

Sticking all that into a global, that may only be used occaisionally, is a waste of space and overhead. The sql call is most likely lower overhead.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.