Gossamer Forum
Home : Products : Links 2.0 : Customization :

How to change category display on add.html?

Quote Reply
How to change category display on add.html?
Question...

I have "Should your add.cgi automatically select what category the user is adding his link into?" set to "1", but I don't like how the category name is displayed on the form, like "General_Knowledge" for example.

Is there way to change that so it will print the entire category path on add.html like:
My Links : This Category: General Knowledge (for example)

Thanks in advance for the help.

Quote Reply
Re: How to change category display on add.html? In reply to
You could either alter the select field sub in db_utils.pl or edit the add sub in site_html_templates.pl


The add sub is prob easier to edit so try the following.

Open site_html_templates.pl and find in the sub_html_add_form:


$category ?
($category = qq~$category <input type=hidden name="Category" value="$category">~) :
($category = &build_select_field ("Category", "$in{'Category'}"));


Replace it with:


if ($db_single_category == 1){
$category = qq~$category <input type=hidden name="Category" value="$category">~;
$category = &build_clean($in{'Category'});
}
else {
$category = &build_select_field ("Category", "$in{'Category'}");
}


Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: How to change category display on add.html? In reply to
Thanks glennu, but no luck, nothing shows up under category when you add that.

Quote Reply
Re: How to change category display on add.html? In reply to
Ahh just realised something try changing it to:

if ($db_single_category == 1){
$category .= qq~$category <input type=hidden name="Category" value="$category">~;
$category .= &build_clean($in{'Category'});
}
else {
$category = &build_select_field ("Category", "$in{'Category'}");
}



Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: How to change category display on add.html? In reply to
Just before you posted that, I realized it needed the ".". So I tried that and now the freakin' thing displays the same thing as always, just prints it again, so it's there twice now. :)

Quote Reply
Re: How to change category display on add.html? In reply to
Okay just tested it this time and seems to work fine...

Delete:

my $category = shift;


And replace the code you added before with:

my $incat = shift;

if ($db_single_category == 1){
my $c_clean = &build_clean($incat);
$category = qq~$category <input type=hidden name="Category" value="$incat">$c_clean~;
}
else {
$category = &build_select_field ("Category", "$in{'Category'}");
}


Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: How to change category display on add.html? In reply to
Glenn, that did it. Thanks man!

Quote Reply
Re: [glennu] How to change category display on add.html? In reply to
Hi

I'd like to use your mod but i use the 'nonenglish modification' mod.

Here is the code :

sub site_html_add_form {
# --------------------------------------------------------
# This routine determines how the add form page will look like.
#
&html_print_headers;

# my $category = shift;
# *********************** nonenglish modification - begin ****************
# $category ?
# ($category = qq~$category <input type=hidden name="Category" value="$category">~) :
# ($category = &build_select_field ("Category", "$in{'Category'}"));
my ($kategorie) = &kategorie_title_mb ($category);
$category ?
($category = qq~$kategorie <input type=hidden name="Category" value="$category">~) :
($category = &build_select_field ("Category", "$in{'Category'}"));
# ************************* nonenglish modification - end ******************

print &load_template ('add.html', {
Category => $category,
%globals
});
}




Is there still a way to use your mod ?

Tanx Laugh
Quote Reply
Re: [B316] How to change category display on add.html? In reply to
When there isn't a refer directly form your own site the category stays empty. I modificated this mod a little bit so it checks the incat if it contains any category info.

if ($db_single_category == 1, $incat){
my $c_clean = &build_clean($incat);
$category = qq~$category <input type="hidden" name="category" size="10" value="$incat">$c_clean~;
}
else {
$category = &build_select_field ("Category", "$in{'category'}");
}

Athair
Quote Reply
Re: [athair] How to change category display on add.html? In reply to
Hello,

I am wanting to make one more modification to this category addition. When someone clicks add to the directory while in a specific category, I am wanting the original pull down list to appear however I would like the category they were in to be selected.

<option selected>Category / Sub Cat</option>

I am not sure how to add the selected part to the build_select_field incat variables. Any help would be appreciated!

Best,

- Andy


Pickle Network
Network of websites both salty and dill.
Quote Reply
Re: [asmith] How to change category display on add.html? In reply to
This is done by doing as mentioned at the start of this thread:

Quote:

I have "Should your add.cgi automatically select what category the user is adding his link into?" set to "1", ...

That's in links.cfg.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] How to change category display on add.html? In reply to
PerlFlunk,

Yes I have followed the instructions above, however it was my understanding that when someone clicks add from a specific category, it displays that category as text, am I not correct?

I am wanting it to display the category in a pull down menu so for instance if the user decides there is a more appropriate category he can select an alternate. I will review the above once more.

Thanks,

Andy


Pickle Network
Network of websites both salty and dill.
Quote Reply
Re: [asmith] How to change category display on add.html? In reply to
OK, then set the option to '0' and you should get the drop-down list you want. I have not tried it, but it seems to be logical...Crazy


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] How to change category display on add.html? In reply to
PF,

This did indeed display the pull down menu, however what I originally was asking was how do I get the pull down menu to automatically select the category that the user was recently in.

I am assuming it will have something to do with an array or a loop to figure out how many categories there are, and match up the most recently visited one then selecting that category in the drop down menu.

Little over my head but I know it can be done, thanks for your help.

- Andy


Pickle Network
Network of websites both salty and dill.
Quote Reply
Re: [asmith] How to change category display on add.html? In reply to
That's over my head, good luck! Wink


Leonard
aka PerlFlunkie
Quote Reply
Re: [asmith] How to change category display on add.html? In reply to
  
In Reply To:
Hello,

I am wanting to make one more modification to this category addition. When someone clicks add to the directory while in a specific category, I am wanting the original pull down list to appear however I would like the category they were in to be selected.

<option selected>Category / Sub Cat</option>

I am not sure how to add the selected part to the build_select_field incat variables. Any help would be appreciated!

Best,

- Andy

Hi Andy

It's quitte easy to do that :

Replace the red part

if ($db_single_category == 1, $incat){
my $c_clean = &build_clean($incat);
$category = qq~$category <input type="hidden" name="category" size="10" value="$incat">$c_clean~;
}
else {
$category = &build_select_field ("Category", "$in{'category'}");
}

in to

if ($db_single_category == 1, $incat){
my $c_clean = &build_clean($incat);
$category = &build_select_field ("Category", $incat);
}
else {
$category = &build_select_field ("Category", "$in{'category'}");
}

Cheers

Athair

Last edited by:

athair: Apr 15, 2004, 2:10 AM
Quote Reply
Re: [athair] How to change category display on add.html? In reply to
Works like a charm. I could of figured that one out, thanks I really appreciate it!

- Andy


Pickle Network
Network of websites both salty and dill.