Gossamer Forum
Home : Products : Links 2.0 : Customization :

Select field on templates

Quote Reply
Select field on templates
Hi all!

After having added select field as new fields to links.def and the $db_select_fields array, now how can I have e.g. the add.html template automatically build this select tag?

What must I put into the template code?

Thanks
Quote Reply
Re: Select field on templates In reply to
I think you just have to put <%fieldname%> into the templates.
I'm not sure but this should work if you have difined it correctly.
cya,

nikolai
Quote Reply
Re: Select field on templates In reply to
Hmmm . . .

this only brings an "unknown tag" error ...

Is there anything else I need to define for new fields other than in links.def ?
Quote Reply
Re: Select field on templates In reply to
I don't remember how it works yet,
have a look in the forum, this topic has been discussed several times before.
And try the FAQ - maybe ther's a solution.
cya,

nikolai
Quote Reply
Re: Select field on templates In reply to
You have to add the following codes at the top of your sub site_html_add_form and sub site_html_add_failure in the site_html_templates.pl file:

Code:
my $field = shift;
my $clean_field = &build_clean($field);
$field ?
($field = qq~$clean_field <input type=hidden name="FieldName" value
="$field">~) :
($field = &build_select_field ("FieldName", "$in{'FieldName'}"));

Change $field to a name of your field like if it is something like State, then change it to $state. Then use the COMPLETE FIELD NAME in the links.def where I have written FieldName.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.
Quote Reply
Re: Select field on templates In reply to
Thanks !

That worked!
Quote Reply
Re: Select field on templates In reply to
You're welcome.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.
Quote Reply
Re: Select field on templates In reply to
Hmmmm, guess that was too early ...

Would this be correct, if having more than one of these fields?

my $Werbung = shift;
my $clean_field = &build_clean($Werbung);
$Werbung ?
($Werbung = qq~$clean_field <input type=hidden name="Werbung" VALUE="$Werbung">~) : ($Werbung = &build_select_field ("Werbung", "$in{'Werbung'}"));
my $ErscheintPro = shift;
my $clean_field = &build_clean($ErscheintPro);
$ErscheintPro ?
($ErscheintPro = qq~$clean_field <input type=hidden name="ErscheintPro" VALUE="$ErscheintPro">~) : ($ErscheintPro = &build_select_field ("ErscheintPro", "$in{'ErscheintPro'}"));


I still get an "unknown tag error" ...
Quote Reply
Re: Select field on templates In reply to
 
Ehm,

I also have to put these into the load_template things like

Werbung => $Werbung

right?
Quote Reply
Re: Select field on templates In reply to
Correct...You are doing the right steps.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.
Quote Reply
Re: Select field on templates In reply to
Eliot,

what do I do wrong, it is not putting through the variables to the success form...

I am using the add_confirm module.

Maybe you can have a look at www.newsletters.de

Thanks
Quote Reply
Re: Select field on templates In reply to
Another question:

How can I have these select field on my modify-template?

There I only get the value but no select field?
Quote Reply
Re: Select field on templates In reply to
 
Quote:
what do I do wrong, it is not putting through the variables to the success form...I am using the add_confirm module.

Uh...for the confirmation page, all you need to do is add hidden fields for each select field.

And in the success page, all you do is put the field name tag, like <%Category%>.

And for the modify templates...you add the codes I gave you to all the modify routines in the site_html_templates.pl.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Select field on templates In reply to
For the modify_failure sub, you need to use the following codes, you need to use the following codes (sorry for the confusion)...

Code:
my $field = &build_select_field ("FieldName", "$in{'Fieldname'}");

Then define the tag:

Code:
field => $field,

Do not use capitals of the field tag, it must be lower case.

Regards.

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Select field on templates In reply to
For the modify templates ...

although all new entries go through well (add.cgi) with the modify I have major problems.

For the site_html_modify_form I had to rename the $in parts into $rec so it would do anything.

However, now it displays field names instead of values under several field. And ... they are mixed, meaning that field name 5 is displayed as field value 10 for example.

Is there anything I have to leave out in the modify sub's. For example the category field does not display any category, especially if I leave the my $category = shift; thing in there ...

Thanks again if anyone can help ...
Quote Reply
Re: Select field on templates In reply to
Please post the codes you are using in the modify sub-routines.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Select field on templates In reply to
sub site_html_modify_failure {
# --------------------------------------------------------
# This routine determines how the modify failure page will look like.

## new

my $Werbung = shift;
my $clean_field = &build_clean($Werbung);
$Werbung ?
($Werbung = qq~$clean_field <input type=hidden name="Werbung" VALUE="$Werbung">~) : ($Werbung = &build_select_field ("Werbung", "$in{'Werbung'}"));

my $ErscheintPro = shift;
my $clean_field = &build_clean($ErscheintPro);
$ErscheintPro ?
($ErscheintPro = qq~$clean_field <input type=hidden name="ErscheintPro" VALUE="$ErscheintPro">~) : ($ErscheintPro = &build_select_field ("ErscheintPro", "$in{'ErscheintPro'}"));

my $ErscheintVerb = shift;
my $clean_field = &build_clean($ErscheintVerb);
$ErscheintVerb ?
($ErscheintVerb = qq~$clean_field <input type=hidden name="ErscheintVerb" VALUE="$ErscheintVerb">~) : ($ErscheintVerb = &build_select_field ("ErscheintVerb", "$in{'ErscheintVerb'}"));

my $Mediadaten = shift;
my $clean_field = &build_clean($Mediadaten);
$Mediadaten ?
($Mediadaten = qq~$clean_field <input type=hidden name="Mediadaten" VALUE="$Mediadaten">~) : ($Mediadaten = &build_select_field ("Mediadaten", "$in{'Mediadaten'}"));

my $Sprache = shift;
my $clean_field = &build_clean($Sprache);
$Sprache ?
($Sprache = qq~$clean_field <input type=hidden name="Sprache" VALUE="$Sprache">~) : ($Sprache = &build_select_field ("Sprache", "$in{'Sprache'}"));

my $AufnahmeVia = shift;
my $clean_field = &build_clean($AufnahmeVia);
$AufnahmeVia ?
($AufnahmeVia = qq~$clean_field <input type=hidden name="AufnahmeVia" VALUE="$AufnahmeVia">~) : ($AufnahmeVia = &build_select_field ("AufnahmeVia", "$in{'AufnahmeVia'}"));

## new end


my $errormsg = shift;
if ($in{'Category'}) {
($in{'Category'} =
qq~$in{'Category'}<input type=hidden name="Category" value="$in{'Category'}">~);
}
else {
if (!@exclude_categories) {
($in{'Category'} = &build_select_field ("Category"));
}
else {
($in{'Category'} = &get_cat_select_list);
}
}
&html_print_headers;
print &load_template ('modify_error.html', {
error => $errormsg,
%in,
Category => $category,
Werbung => $Werbung,
ErscheintPro => $ErscheintPro,
ErscheintVerb => $ErscheintVerb,
Mediadaten => $Mediadaten,
Sprache => $Sprache,
hopto => &hopto_category,
%globals
});
}
Quote Reply
Re: Select field on templates In reply to
Where would I add all the values for the new select field?

Let's say I added a select field called States.

Where would I put Alabama, Alaska, Arizona, California, Colorado, Connecticut, etc...?

How would I delimit the values? 'valueA|valueB|valueC'

Would it go in links.def?

Many thanks. Smile

Quote Reply
Re: Select field on templates In reply to
In Reply To:
Where would I add all the values for the new select field?
In the Û_select_fields array in the links.def file like you did for the other drop-down menu options, like isPopular, and isNew.

Wink

Example:

Code:
Û_select_fields = (
isNew => 'Yes,No',
isPopular => 'Yes,No',
ReceiveMail => 'Yes,No',
isDetailed => 'Yes,No',
State => 'Alaska,Arkansas'
);
The States need to be separate by commas like the other select fields.

In Reply To:
How would I delimit the values? 'valueA|valueB|valueC'
What do you mean? I think I already answered your question with formatting the State field in the Û_select_fields array.

Now, if you want people to choose multiple values for the State field, then you will have to copy the AltCatgories Mod codes in the db_utils.pl and replace AtCategories with State. Then you will have to format the State field like you have done with the AltCategories field in the site_html_templates.pl file.

In Reply To:
Would it go in links.def?
I think that I have already answered your question.

Regards,


Eliot Lee
Quote Reply
Re: Select field on templates In reply to
Thank you so much AnthroRules. This is one of the last hurdles to setting things up the way that I want. I am very grateful. Smile

In fact, this thread might be worth posting in the Resource Center. What do you think?

Quote Reply
Re: Select field on templates In reply to
I do not like Threads that are posted in the Resource Center...I may post a FAQ/Tutorial about how to set up select fields, but I really don't like seeing Threads that are full of extraneous discussions linked as "Modifications" and "FAQs"...If you notice, many of the Threads (if not all) linked as "Modifications" and "FAQs" generate a lot of new problems and discussions rather than solving issues and problems.

Wink

Regards,

Eliot Lee
Post deleted by PaulW In reply to