Gossamer Forum
Home : Products : Links 2.0 : Customization :

Links Add - display of Category

Quote Reply
Links Add - display of Category
Hi,
I am using a template on my ADD page and using <%category%> to display the loation they are about to post to. As you porbably know it displays as Category/Subcateory... which is perfect.

However, is it possible to remap the display for fields that have spaces and are displayed as New_York/New_York to look like New York/New York.

I know .... picky ..picky ... picky Smile

Thanks
Jeff


[This message has been edited by JWells (edited June 14, 1999).]
Quote Reply
Re: Links Add - display of Category In reply to
Go to db_utils.pl, sub build_select_field. Change this:

Code:
my ($size, %values);

to read:

Code:
my ($size, %values, $field_clean);

Then change:

Code:
foreach $field (sort keys %selectfields) {
($field eq $value) ?
($output .= "<OPTION SELECTED>$field\n") :
($output .= "<OPTION>$field\n");
}

To read:

Code:
foreach $field (@fields) {
$field_clean = &build_clean($field);
$values{$field} ?
($output .= qq|<OPTION VALUE="$field" SELECTED>$field_clean\n|) :
($output .= qq|<OPTION VALUE="$field">$field_clean|);
}

Not only will it change the display for the Add page, but any other page that uses the category list in a drop-down select list (such as the admin screen, or user modify screen, etc.).

I am now looking at a way to do the same for the "hard-coded" categories that display if $db_single_category in links.cfg is set to 1. I'll post something as soon as I have figured it out.

I hope this helps.

[This message has been edited by Bobsie (edited June 14, 1999).]
Quote Reply
Re: Links Add - display of Category In reply to
Here is how to change things so that the single category will also display without the "/" and "_" in the category names. These instructions are in addition to what I stated in my previous message.

Go to sub site_html_add_form in either site_html.pl (if not using templates) or site_html_templates.pl (if using templates).

Change the following code:

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

to read:

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

That should do it.

[This message has been edited by Bobsie (edited June 14, 1999).]
Quote Reply
Re: Links Add - display of Category In reply to
Bobsie,
Thanks for the great tips Smile

You mentioned something people using:

$db_single_category in links.cfg is set to 1.

I'm doing this as well. If you change it at that level, I should go into my database using a text editor and replace all "/" with
" " shouldn't I ? .... or my searches will always come back "0 found"

Actually I guess I'm a little confused by the set "1" comment. Will this changs relfect my database or are they only comestic changes for display purposes. I really don't mind changing the data in my database if it is required. Heck with a text editor and "find & replace" it might take me a whole 3 mintues if I need to do it Smile

Thanks,
Jeff
Quote Reply
Re: Links Add - display of Category In reply to
Bobsie,

OUTSTANDING!!! Smile It looks great!

But, I'm still a bit confued when it comes to using it within an ADD Template. Has it altered the data to be saved to:

New York: New York

or

is the saved data still

New_York/New_York

Doesn't matter to me, just need to know if I need to fix my database to reflex these changes.

I'm using in an ADD template as:
$db_single_category = "1"

Once again, thanks it looks very professional now.
JEff




[This message has been edited by JWells (edited June 14, 1999).]
Quote Reply
Re: Links Add - display of Category In reply to
Jeff,
These changes are, as you put it, only cosmetic... there is no need for you to change anything in the database itself.

Bobsie,
Thanks for another great tip. I would *never* have thought of that.

Phoenix
Quote Reply
Re: Links Add - display of Category In reply to
Just a question?

Do you not need to add the same code

#### new code for removing/ and _
my $clean_category = &build_clean($category);
#### end new code

to subs add_failure, modify_form and modify_failure?

Thanks
Quote Reply
Re: Links Add - display of Category In reply to
JWells,

Quote:
Actually I guess I'm a little confused by the set "1" comment.

If the $db_single_category in links.cfg is set to 1, then when a user is on your category page and clicks on the "Add a Link" option, the category displayed is the category of the page they click the "Add a Link" on. No drop-down category selection list is displayed. If they click on "Add a Link" from any non-category page, they will get a drop-down category selection list.

If $db_single_category is set to 0, the drop-down category selection list is always displayed no matter which page they were on when they clicked "Add a Link".

Quote:
is the saved data still

New_York/New_York

Yes it will be correct in the database. That is the purpose of the line that reads:

Quote:
($category = qq~$clean_category <input type=hidden name="Category" value="$category">~) :

The input tag being passed as part of $category or <%Category%> ensures that the true category name, with all the underlines and slashes, is recorded in the database. That is why it is included in the add form. $clean_category or <%clean_category%> is only used for display purposes.

socrates,

Quote:
Do you not need to add the same code to subs add_failure, modify_form and modify_failure?

How should I know? I never got that far with this Smile However, you are probably right. I just didn't think of it. But remember, it will not affect anything even if it is left out because $clean_category is just for display purposes. I would put the code in those routines, though, if for no other reason than consistency.

Enjoy the mod. I will probably publish a complete mod and add it to the resource center soon.
Quote Reply
Re: Links Add - display of Category In reply to
Socrates,

I take back some of what I said. You do not need to include the code in sub site_html_modify_form. That's because, at that point, only the user knows what category he/she wants to put the link into. It may be one of the items that are going to be changed. However, adding the code to both sub site_html_add_failure and sub site_html_modify_failure should be done.

Sorry about that.
Quote Reply
Re: Links Add - display of Category In reply to
I am still confused, Bobsie. You mentioned in http://www.gossamer-threads.com/...m11/HTML/000556.html that you have written "better" codes for showing clean categories in this Item.

Yet there is nothing in this Item that addresses the problem of grayed out category field in the Add Form if people access the Add Form from a non-category page? Are there any solutions to this problem?

Thank you for your time.

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Links Add - display of Category In reply to
Maybe it is me that is confused?

When I went to www.anthrotech.com/cgibin/wwwvl/add.cgi there is no "grayed-out" category field in the add form. Instead, a drop-down selection list appears. This is how it is supposed to work. The only time a "grayed out" category field is displayed is when using the Add A Site link from a category page although, on your system, it still displays a drop-down selection list.

So what am I missing?
Quote Reply
Re: Links Add - display of Category In reply to
Problem fixed. Thanks. Working like a charm.

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited June 25, 1999).]

[This message has been edited by Eliot (edited June 25, 1999).]

[This message has been edited by Eliot (edited June 25, 1999).]
Quote Reply
Re: Links Add - display of Category In reply to
Yep try adding the same code to:
subs add_failure, modify_form and modify_failure

... or thier template files if you are using those

Jeff

Appended MSG:
I see you're fixed now Smile



[This message has been edited by JWells (edited June 25, 1999).]
Quote Reply
Re: Links Add - display of Category In reply to
Real quick....if I add the modifications that Bobsie has listed here, will I still be able to use the <%Category%> tag or will I have to go and change all those to <%category_clean%>?? I just don't want to start getting Unknown tags all over. I know phoenix said it was for comsetic purposes only, but I just thought I'd verify first.

Thanks
Quote Reply
Re: Links Add - display of Category In reply to
You use <%Category%>.

Since the tag you defined is:

Code:
Category => $category,

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Links Add - display of Category In reply to
Actually, I was just wanting to get rid of the ( _ ) underscores in the category names, and was wondering if I could use both tags without running into Unkown tag problems? I just didn't want to dig through every file and change <%Category%> to <%category_clean%>, because the way they are displaying on some pages right now is fine (with _) but, on some new pages that I'm doing I wanted to get rid of the ( _ ). Anyway, does my question make sense? If not, don't worry about, it's no big deal.

Thanks
Quote Reply
Re: Links Add - display of Category In reply to
If you are referring to Category pages in your directory, the pages are already built clean...refer to the sub build_linked_title in the nph-build.cgi file.

You should see the following lines:

Code:
$last = &build_clean(pop @dirs);

If this is not what you are referring to, you are NOT being very clear in your posts.

Wink

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: Links Add - display of Category In reply to
It was a confusion on my part....I thought that after you installed this mod, you must use the tag <%category_clean%> instead of <%Category%> ----- I must have read that somewhere else and just confused the two. It's all clear now, thanks Eliot.
Quote Reply
Re: Links Add - display of Category In reply to
Glad you finally figured it out.

Regards,

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