Gossamer Forum
Home : Products : DBMan : Installation :

Customizing the Short Display

Quote Reply
Customizing the Short Display
Hi There, I'm Back!

Anyway, Just a quick question. In the fields for Type & Category I'm having trouble putting in the number of choices we need (25+ each). I keep getting a CGI syntax error.

I even tried to put a drop-down in the html.pl instead (like the one for Sort Order in the Search page), but I couldn't get that to work either.

Any suggestions? Smile


------------------
BigBritchs
BigBritchs@IDunno4Recipes.com

Quote Reply
Re: Customizing the Short Display In reply to
Your syntax error might have something to do with print statements. I would have to see your script in order to know.

If you could put your html.pl file in a web-accessible directory (one where you woule place html files) and rename it to something like html_pl.txt, I'll take a look at it.


------------------
JPD





Quote Reply
Re: Customizing the Short Display In reply to
Hi Again!

OK. I put ALL the relevant files in:
http://63.67.58.48/dbman

I think the offending file is the archive.cfg. I put some comments near the problem area along with a copy of the error message I've been getting.

One possible solution I was wondering about: Is it possible to use a variable referring to another file (say "options1.txt" or something like that) into the code instead of trying to list all possible drop-down options there in the .cfg file?

Also, two other quick issues I hope you can help with:

1) Why does some info disappear when trying to modify a record? When I open an exiting record in "Modify" the 2 drop-down fields (Type & Category) as well as the "Source" field are returned blank. Can this be fixed?

and,

2) Is there an easy to use script modification that would give default users the option to print the record they are viewing either to a hardcopy or to a file? Our users really want this and would be very excited if we could provide it.

I know I'm asking a lot. Believe me we appreciate your help.

Thanks,

------------------
BigBritchs
BigBritchs@IDunno4Recipes.com



[This message has been edited by BigBritchs (edited June 05, 1999).]
Quote Reply
Re: Customizing the Short Display In reply to
I had a little trouble accessing your files. Good thing I knew which file I needed to download.

The reason you're getting the syntax error is that you need a comma after the end of the last option in the Category field

Code:
...Snacks,Sugar-Free,Large Groups,Other,',
Type => 'African,American,...

The problem you're having with modifying records is that you have spaces in your select list definitions.

Code:
What you have:
Category => 'Appetizers, BBQ & Outdoor, Beverages, Breads, Breakfasts,

What you should have:
Category => 'Appetizers,BBQ & Outdoor,Beverages,Breads,Breakfasts,

Same thing with the Type select list.

I'm not sure about your Source field. It's probably something in your html.pl file, but I couldn't access that file.

Regarding your "options1.txt" file idea. You could do that. Sorta. You'd probably need to name it options.pl and you'd need to have a line in your .cfg file --

require $db_script_path . "/options.pl";

You would need to set up the variables the same way as they are set up in the .cfg file, too:

Code:
%db_select_fields = (
Category => 'Appetizers,BBQ & Outdoor,Beverages,...
);

I'm not sure what you'd gain by doing that, though.

Regarding printing out a hard copy, you could set up an html_record type subroutine that would format the data for printing. Then users could use the print function on their browsers to print it.



------------------
JPD





Quote Reply
Re: Customizing the Short Display In reply to
Thanks JPD!

I just knew I had missed something stupid like a simple comma or the spaces after the commas in the options lists. I just didn't know what it could be.

My only reason for thinking about a seperate options.pl file was that I thought maybe it was the length of the lists that was causing the monkey wrench in the works.

In light of the fact that I know so little about what I'm doing, would I be out of line to ask for a little more detail (or possibly an example) of the "html_record type subroutine" you mention in regards to printing out records? Could it be an option that would be extremely simple for the end user? Not many of our visitors are any more computer/internet literate than I am!

Once again, thanks for comming to the rescue!


------------------
BigBritchs
BigBritchs@IDunno4Recipes.com



[This message has been edited by BigBritchs (edited June 06, 1999).]
Quote Reply
Re: Customizing the Short Display In reply to
You can make a subroutine -- let's call it "sub html_record_printout."

You would add it to your html.pl file, starting with the line

sub html_record_printout {

and ending with a

}

In the middle, you would print out what you want the page to look like. There are a lot of possibilities here, and I really hate going into the details of how to do one possibility, only to find you want something else. Smile

So, what do you want to print out? One record only? The results of all records that are returned from a search?

Once I get an idea of what you want, I can help you better.


------------------
JPD





Quote Reply
Re: Customizing the Short Display In reply to
First, I want to thank you for your help again. I made the corrections you suggested and all is working GREAT!

For now, I guess we'll put the print issue on the back burner. I need to define better what exactly we want.

Anyway, 2 other issues are more immediate:

1) How can we force the "List All" to return records in alpha order. I suspect it can be done by modifying the following line in the html.pl:

print qq!| <A HREF="$db_script_link_url&view_records=1&$db_key=*">List All Recipes</A> ! if ($per_view);

But I am not sure how or if this can be done.

2) I an earlier thread, I mentioned a default that would list all records, seperated by their respective categories and listed in alpha order. Is there any possibility this may be possible anytime soon?

Once again, thanks for the help. I assure you it will be appriciated.

Regards,
Big Britchs

PS - Come by the site if you want to see how it is working out!



------------------
BigBritchs
BigBritchs@IDunno4Recipes.com

Quote Reply
Re: Customizing the Short Display In reply to
Glad my suggestions worked for you. Smile

Quote:
1) How can we force the "List All" to return records in alpha order. I suspect it can be done by modifying the following line in the html.pl:

print qq!| <A HREF="$db_script_link_url&view_records=1&$db_key=*">List All Recipes</A> ! if ($per_view);

But I am not sure how or if this can be done.

Yep. Your suspicions are correct. Smile

Look at the field you want to sort by in your .cfg file -- what you want is the number of that field.

Then add the &sb=# to the "List All" link. If the field you want to sort by is field 1, it would be

print qq!| <A HREF="$db_script_link_url&view_records=1&$db_key=*&sb=1">List All Recipes</A> ! if ($per_view);

Quote:
2) I an earlier thread, I mentioned a default that would list all records, seperated by their respective categories and listed in alpha order. Is there any possibility this may be possible anytime soon?

This has been the bane of the existence of DBMan users probably from the beginning -- at least since I've been hanging around the forum. I thought I had an idea, but it fizzled. I see the reason Alex didn't put it in the script in the first place.

I don't see it happening.

There is a way to work around it, though, at least to sort within categories, even if you don't have a label for the category. (We might even be able to work that out. It seems I recall someone had an idea along those lines a couple of months ago.)

The workaround is to add another field to your database which you would just use to sort by. If, for example, you wanted to group your results by category and then alphabetize within the category by name -- isn't that exactly what you want to do? Smile -- your sorting field would consist of the category and the name, all squished up against each other. So a Category of "Cookies" and the name of "Snickerdoodles" (my favorite!) would have a sort field of "CookiesSnickerdoodles." This would be a hidden field on your form and you could add a line to the add_record subroutine in db.cgi which would automatically set the field, based on inputs from other fields.

Then, in order to sort the records, you would use the field number of the sort field.

I can pursue this with you to get the categories to print out, if you're interested.

We can also work on the printout, if you want to. It shouldn't be too hard.

------------------
JPD







[This message has been edited by JPDeni (edited June 06, 1999).]
Quote Reply
Re: Customizing the Short Display In reply to
Hi JPD!

Thanks for your suggestion, but unfortunately I didn't have any success with it. I added the "&sb=3" 3 being the Title field's number, but it still wanted to sort on the db_key which is field #1 (the ID number field).

Question: What would happen if I replaced the db_key variable in the .cfg file with the Title rather than the ID field name? Would that cause problems elsewhere?

Also, your sort feature work-around looks doable. I suppose I could even create a dummy record with only the category name in it to act as a header when the list is displayed, ya think?

As for the print option, we've still got to think that one through, but thanks for your offer to help with it.

Thanks again for all your help.

Regards,
BB

------------------
BigBritchs
BigBritchs@IDunno4Recipes.com

Quote Reply
Re: Customizing the Short Display In reply to
Well, I went to your site and poked around a little bit. I did a "List All" and then changed the "sb=" number to different numbers. Every time I changed the number, I got a different list. The one that gave me what looked to be an alphabetical list was "sb=2." I'm wondering if your Title field is actually field number 2 --

Wait a minute. I just remembered that I downloaded your .cfg file to take a look at it and I still have it on my computer. I hadn't looked closely at that part of it before. You have a problem with your field definitions. They go like this:

Code:
ID => [0, 'numer', 5, 8, 1, '', ''],
Date => [2, 'date', 12, 15, 1, &get_date, ''],
Title => [3, 'alpha', 40, 255, 1, '', ''],
Contributed => [4, 'alpha', 40, 40, 1, '', ''],

You're missing a field 1. You need to renumber your fields. Since you're not using a userid field (even though you have one), you shouldn't have to rebuild your database.

I wouldn't change the key value to Title. You might want to have two "Tuna Casserole" recipes.

Quote:
Also, your sort feature work-around looks doable. I suppose I could even create a dummy record with only the category name in it to act as a header when the list is displayed, ya think?

Great idea. Since all of your "real" records will have a value in the "Title" field, when you do your display you can look to see if there's anything in the "Title" field. If not, it's a category.

In order to make your Sorting field work, without having people need to enter it manually, you'll need to add some code to both the add_record and modify_record subroutines.

In both cases, after the line

$status = &validate_record;

add

$in{'Sort'} = $in{'Category'}.$in{Title};

(That's assuming you call your sorting field "Sort." Smile )

Let me know when you're ready to proceed with the print option.


------------------
JPD





Quote Reply
Re: Customizing the Short Display In reply to
Thanks for saving my butt once again!

Just like me to miss something so obvious. What I need to do is hire someone to beat me with a stick every time I do something stupid. Maybe I'll learn to pay closer attention to the details. I'll try renumbering and adding the hidden "sort" field A.S.A.P. and let you know how it turns out.

Regarding the dummy record for the category sort, I thought I'd put the name of the category in the "Title" field so that when a list of just titles is returned the first record in each category would be the Category name. To accomplish that it might be neccessary to edit the .db file in a text editor and change the sort field entry from "CategoryCategory" (Category+Title) to just "Category" or "Category1A" or "CategoryAAA" so it would show up first. It is a little extra work, but once it was done, I think it'll work OK.

Or I could enter the dummy records first, before adding the line of code to make it automatic, and just manually enter the sort field info (i.e., just the name of the category without any title info). THEN modify the sub routines before any more new records are entered.

What do you think?

Either way I'll have tp go back and modify records already input, but what the "hey" it's only my time, right?

Last question for this issue this time: Can I put HTML in the Title field to make the category header stand out when the final list is returned? Something like <font size="+2" font color="red"><b>Cookies</b></font>?

That's it for now. Yak at ya later.
BB

------------------
BigBritchs
BigBritchs@IDunno4Recipes.com

Quote Reply
Re: Customizing the Short Display In reply to
Don't beat yourself up too bad. It happens to the best of us. Smile

I like the second option best -- adding the "dummy" records first, with no title info. It's easier to tell when a new category comes up.

Wait a minute. I just realized something. This is gonna mess up the number of records per page. The "dummy" record will be considered a record, which you probably don't want. You may need to do something like Mike(?) did, with checking the category each time to be sure it's not a new one.

Regarding the font formatting, you sure can make those changes. No problem at all. But you might want to think about the issue I raised in the last paragraph.

It's really not that hard to do, once you get the sorting field taken care of, and doesn't have to be as complicated as Mike's code.

Here's something, using the default code from the "short" mod. I've included some of the lines that are already there, so you can see where the code is. The new stuff is in bold.

Code:
$long_url = $ENV{'QUERY_STRING'};
$long_url =~ s/\&nh=\d+//;
$long_url =~ s/\&mh=\d+//;

$long_url = "$db_script_url?$long_url&nh=$record_number&mh=1";

print "<TD>"; # do not remove this! It is necessary to make the records display properly

unless ($last_category eq $rec{'Category'}) {
print qq|<font size="+2" font color="red"><b>$rec{'Category'}</b></font></td><td>|;
$last_category = $rec{'Category'};
}





------------------
JPD





Quote Reply
Re: Customizing the Short Display In reply to
Hi JPD!

Ever since I stepped through this looking glass, things keep getting curiouser and curiouser. Maybe I shouldn't work on this past midnight when my brain seems to go to sleep long before I do.

If you would be so kind as to take a look at the site and choose the "List ALL" feature, maybe you can tell me why the records are being returned in such a helter-skelter fashion. Go to:

http://www.63.67.58.48/cgi-bin/dbman/db.cgi?db=archive&uid=default

I have put all the current version of all the relavant files in:

http://www.63.67.58.48/dbman

Or I have a zipped file I can email you if you can't access them there.

I swear if you help me through this, I'll make it up to you. Maybe send you some Snickerdoodles or something Smile!

BB





------------------
BigBritchs
BigBritchs@IDunno4Recipes.com



[This message has been edited by BigBritchs (edited June 08, 1999).]

[This message has been edited by BigBritchs (edited June 08, 1999).]

[This message has been edited by BigBritchs (edited June 08, 1999).]
Quote Reply
Re: Customizing the Short Display In reply to
  Smile Mmmmmmmm good!

The reason your sorting is screwy is that you don't have anything in your "dummy" records in field #10 -- the sorting field. It will always sort blank fields before it sorts fields with something in them.

I know you went to a lot of work making the dummy records, but I really think the better way to go is to take them out (don't hit me! Smile ) and use the category printing syntax I posted yesterday.

Well, now that I look at it, it's not very good either. Hmmmmmm.

Let's try it again.

Code:
$long_url = "$db_script_url?$long_url&nh=$record_number&mh=1";
unless ($last_category eq $rec{'Category'}) {
print qq|<td><$font><font size="+2" font color="red">
<b>$rec{'Category'}</b></font></font></td></tr><tr>|;
$last_category = $rec{'Category'};
}

print "<TD>"; # do not remove this! It is necessary to make the records display properly

This is going to make your viewing list all right, but your delete and modify forms won't work very well. We may need to make a separate subroutine for them.

But give this a try. Take out the dummy records (save a copy of the file, just in case you might want to have them again later) and add the above code. See how it works for printing out your categories.

------------------
JPD







[This message has been edited by JPDeni (edited June 08, 1999).]
Quote Reply
Re: Customizing the Short Display In reply to
I know what you mean about problems when directly editing the .db file. It can get kinda hinky.

I just figured out a way to have only one "if" statement, no matter what they chose to sort by.

Code:
unless ($last_category eq $rec{$db_cols[$in{'sb'}]}) {
print qq|<td><$font><font size="+2" font color="red">
<b>$rec{$db_cols[$in{'sb'}]}</b></font></font></td></tr><tr>|;
$last_category = $rec{$db_cols[$in{'sb'}]};
}

You're probably only going to want to allow people to sort by the Category or the Type fields. Sorting by the recipe title would look a little odd -- giving you a red title and then a link below it. If you want to be able to sort by Title, too, though, It might be a good idea to "disable" the printing of the header.

Wrap the whole code above in an "unless" statement:

Code:
unless ($in{'sb'} == 2) {
[the code above]
}

I can see you limiting sorts to either Category, Type or Title. BTW, since you want to offer the options of sorting by fields other than Category, it's probably a good idea that you took out the sorting field.

I can smell those cookies in the oven right now!


------------------
JPD





Quote Reply
Re: Customizing the Short Display In reply to
Oh, dear. I didn't make myself clear. I hope you saved your previous .db file.

All you needed to do was delete the "dummy" category records. Leaving in the sorting field is a very good thing.

On the bright side, your categories are sorting just hunky dorey. (They look mahvelous!! Smile )

Do you want to offer visitors a choice to sort by another field, or do you want to make it always be by category?

If you want to offer visitors a choice, but to have it default to Category, you'll need to make up your own sort by select field in sub html_search_options.

Instead of

Code:
Sort By:
<SELECT NAME="sb">
<OPTION>---
~; for (my $i =0; $i <= $#db_cols; $i++) { print qq~<OPTION VALUE="$i">$db_cols[$i]</OPTION>\n~
if ($db_form_len{$db_cols[$i]} >= 0); } print qq~
</SELECT>

use

Code:
Sort By:
<SELECT NAME="sb">
<OPTION value="4">Category
<OPTION value="1">Fieldname
[fill in as many field numbers and names as you want to offer]
</SELECT>

If, instead, you just want it to default to sorting by Category, without the visitors having a choice, remove all of the original code above from sub html_search_options and, instead, just after the hidden fields in sub html_search, add

<input type="hidden" name="sb" value="4">

You'll also want to put that in sub html_view_failure in the same place.

It doesn't hurt anything to have the &sb=4 on the "Search" link, but it doesn't do any good either. (and not to be nit-picky, but you might have missed that you left the "r" out of Search in your footer)

BTW, if you didn't keep a copy of your old .db file with the Sorting fields intact, I still have a copy that I downloaded from your site when I was debugging your other problem.

I like extra cinnamon on the Snickerdoodles. Wink

------------------
JPD





Quote Reply
Re: Customizing the Short Display In reply to
Hi JPD!

Not to worry, you made yourself clear about what needed to be removed. I was just having great difficulty getting the records to return with any consistancy. They would come back with dates, ID #s, etc. in the search results instead of titles! From my previous experience with database programming, I knew this had to be something like a missing delimiter or invalid fields or something similar. So I decided for the time being to take one step back before trying to go two steps forward. I did save a copy (actually 2 or 3) of the original file, but I may go back and start from scratch. Smile

================================================
Do you want to offer visitors a choice to sort by another field,
or do you want to make it always be by category?
================================================

Because users can only view and search, I think I want to make Category the default sort when using the "List ALL" feature.

But users should be able to chose another sort option when they are using the search feature's drop-down options. The only problem I see with this is that the Category headers still print in the final result. Could the print code be written with a variable so that whichever field is chosen as a sort criteria, that would be the field used as a header? i.e.,:
unless ($last_"VARIABLE" eq $rec{'"VARIABLE" '}) {
print qq|<td><$font><font size="+2" font color="red">
<b>$rec{' "VARIABLE" '}</b></font></font></td></tr><tr>|;
$last_"VARIABLE" = $rec{' "VARIABLE" '};
}

or would it be neccessary to write a series of "IF" statements like:

if sb=4
unless ($last_category eq $rec{'Category'}) {
print qq|<td><$font><font size="+2" font color="red">
<b>$rec{'Category'}</b></font></font></td></tr><tr>|;
$last_category = $rec{'Category'};
}
etc.

Just a thought, though I know my code has to be way off, but I think you'll understand what I mean.

Meanwhile, I'll make the changes you suggest to the sub html_search_options for two reasons:
1) I just like it better and because I understand it, it will be easier to edit in the future, AND
2) It allows me to control which fields will be made available for sorting (we go through all the trouble to make a nice list sorted by category and some numbskull comes in and sorts by ID# - WHY?).

Anyway, talk to you later. I am on my way to the store for extra cinnamon!

BB






[This message has been edited by BigBritchs (edited June 09, 1999).]
Quote Reply
Re: Customizing the Short Display In reply to
Hi JPD!

OK, I stripped out the dummy records and the sort field info out of the database (that took a little doing! Thankfully, there weren't as many records as there might have been.) and commented out the lines referring to the sort field. I eliminated it totaly, even removing it from the field definitions.

Then I added the code you provided. Looks GREAT! Alphabetising the individual recipies will have to wait.

Now, how do I make sorting on the Category field the default, at least for the search function. Casual viewers only have view and search permissions, only administrators are allowed to add, delete, or modify, so those functions aren't so critical, but it would be nice if they would default to sorting on the Category field, too, if it is not too much trouble.

I tried putting the same "&sb=4" (Category = 4) everywhere I could think of with no result.

I can see the end of the tunnel and can almost smell those Snickerdoodles!

BB

------------------
BigBritchs
BigBritchs@IDunno4Recipes.com



[This message has been edited by BigBritchs (edited June 09, 1999).]
Quote Reply
Re: Customizing the Short Display In reply to
COOL! I'll give that a try ASAP and let you know how it works out.

Oh, yeah, I'll fix my typo in the footer, too.

Your help has been invaluable.

Uh oh, gotta run. I think I smell somethin burning!

BB


------------------
BigBritchs
BigBritchs@IDunno4Recipes.com

Quote Reply
Re: Customizing the Short Display In reply to
Eureka! Success! Joy!

JPD - It works like a charm!

I nominate you for "Scarecrow of the Month!"
(A scarecrow being someone *outstanding* in their field, of course!)

I'm gonna name my first-born after you!

If I discover a new continent, I'll plant a flag in your honor!

THANKS FOR A GREAT JOB!!! LOOOKS FAAANTAAASTIC!!!

I Dunno (ID for short) sends thanks & kudos, too!

We are still testing recipes for those Snickerdoodles. They have to be the best, ya know.

BTW - Do you have your own Home on the Internet? I'd love to drop in for a visit! I want to keep in touch.

Regards,
BigBritchs, I Dunno, & the gang at
IDunno4Recipes.com

------------------
BigBritchs
BigBritchs@IDunno4Recipes.com

Quote Reply
Re: Customizing the Short Display In reply to
Thank you. It's been fun.

I know that you've found it by now, but in case anyone else is interested, I have my own domain -- www.jpdeni.com. Probably the part you'd be most interested in is www.jpdeni.com/dbman/

Please post here when you go "live." It's great to see the script in action.

I'm already anticipating sitting down with a cup of Earl Grey and a pile of Snickerdoodles. Heaven!!!!

------------------
JPD