Gossamer Forum
Home : Products : DBMan : Customization :

Short/Long list mod need help

Quote Reply
Short/Long list mod need help
Hello everyone,

I have the short/long display mod installed and working fine. I want to add a new feature that will display the last 5 short list records on the long_record result page. Here is an example of what I have so far:

http://www.makeitsimple.com/...ds&nh=1&mh=1

Here is the for loop that I setup for the example.

$i = 1;
for (0 .. 5 - 1) {
&html_record_ssi_2(@hits);
++$i;
}

I want to display the last five records added to the database but have no clue at this point how to proceed.

Any help will be greatly appreciated.
Quote Reply
Re: Short/Long list mod need help In reply to
What is your key field? If it's a counter, you would just need to use

&sb=number of key field&so=descend&mh=5

in your URL.

I notices that you have &sb=ID. The value of sb is the number of the field, not the name.


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





Quote Reply
Re: Short/Long list mod need help In reply to
Hi Carol,

I can see you are being blasted with questions again big time. Vacations NEVER last long enough and sometimes returning to daily life can be a real drag. I Hope things are going well for you, and remember life IS a drag for us when you are gone. Wink

I know that &sb=ID should be &sb=0 because zero is the the field for key (ID) but for some reason 0 (zero) gives me problems and ID works fine. That isn't really the problem or question though.

Did you go to the link above? That link is just an example of the output that I am trying to get.

The query string to display the five latest short display records would have to come from a manually setup loop the way I see it.

The example page is the output from the long_record subroutine which is only called on max_hits = to one. So I believe some Perl trickery that you do so well would be needed.

Cheers!

------------------
Larry "NgtCrwlr" Mingus
www.makeitsimple.com

Quote Reply
Re: Short/Long list mod need help In reply to
I hadn't gone to your URL, but I did now and it really doesn't help a whole lot for me to understand what you need. I did some playing around, though, with the search.

The reason that sb=ID works is that it's field 0, which is what things get sorted by anyway, especially if it's a counter. I tried using sb=0 and it worked just as I thought it would.

The following URL:

http://www.makeitsimple.com/cgi-bin/dbman/blurb_news/dbview.cgi?db=blurb&uid=default&Headline=*&sb=0&so=descend&view_records=1&nh=1&mh=5

gave me the last 5 records:

Voodoo3 and AGP4x Jul-28-1999 17:29:39
Weekend Report Jul-17-1999 22:10:48
Changing Faces... Jul-13-1999 03:42:51
Server Problems! Jul-12-1999 07:01:37
Yes! Games! Jul-10-1999 21:16:18

The only thing that came up that you may not want are the links to the rest of the pages.

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





Quote Reply
Re: Short/Long list mod need help In reply to
LOL sometimes getting to the real point can be so difficult. It'not you Carol, it's me not being clear enough.

The example page is the output that I want. It is a combination of both Long_record (one record being displayed) and the short list (5 records displayed) both outputs being displayed on one page.

The way the original long/short display mod is setup you can have either long OR short but not both on the same page.

This (new mod) would give the visitor the option to go directly to a long display for any of the latest five headlines without needing to return to the short record list or use the next/previous links.

Does that make sence? LOL Wink


------------------
Larry "NgtCrwlr" Mingus
www.makeitsimple.com

Quote Reply
Re: Short/Long list mod need help In reply to
I see. Okay. Hmmmmmmmmmm.

I had completely missed the colum on the side of the page. Sorry. Smile

This is tough. I can give you the links to the other records with no problem. The problem comes in getting the information from them for the title and the time/date. The way the search works is that it only pulls the info for what is going to be displayed. So it only has the values for what is in the "long" record.

I suppose you could do another search for records within sub html_record_long.

Is this only going to be used with a "last 5 records" search? If so, I'll have to figure out a way to tell the script when to do the extra search.



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





Quote Reply
Re: Short/Long list mod need help In reply to
Yeehaw! now we are on the same page. Wink

I think the best way would be if possible, to submit a second search for the short list display done internally in the long record subroutine or a call to another subroutine.

I would like to see it as a separate subroutine that could be configured as to how many headlines to display, sort order, etc. Couldn't we setup variables to pass to the sort routine manually?

For now if you can just give me a little push on how to pass data to the search subroutine manually I think I may be able to help. HAH.. (may) be able help to is the right word. Wink


------------------
Larry "NgtCrwlr" Mingus
www.makeitsimple.com

Quote Reply
Re: Short/Long list mod need help In reply to
It really does help me if I sketch out the procedure first, so that's what I'm going to do now. Smile Besides, you can tell me if I'm heading in the wrong direction.

You can do it in a separate subroutine or not. It really doesn't matter.

Actually, I think you can just set $in{'nh'}=1 and $in{'mh'}=5 and do another search by using something like
my ($status2,@hits2) = &query{'view'};
and then using the same syntax as in html_view_records to go through each record.

Then print out the search results in the column, with the links like in html_record. If you wanted to get fancy, you could try to eliminate the link for the record you're currently on.

You shouldn't have to worry about passing variables to the subroutine, since all of the search variables are global. (Am I telling you more than you want to know? Smile )

Does this make any sense? Smile

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





Quote Reply
Re: Short/Long list mod need help In reply to
More than I want to know... NEVER! Wink

My problem is getting a grip on it, I do pretty well on my own but then I come to the old brick wall of needing help.

At this point I don't understand arrays and what $in{'nh'}=1 is actually doing internally. I do understand that you are setting next hit to = one but I don't have a grip on $in other than I think it is an array (or something) that holds the query variables.

So yes I do need help, and I hope that I am not taxing you too much. I am trying hard to get up to speed and keep up.

------------------
Larry "NgtCrwlr" Mingus
www.makeitsimple.com

Quote Reply
Re: Short/Long list mod need help In reply to
You're doing fine, Larry. Smile

The %in hash (a hash is an array that uses names instead of numbers to access the individual parts -- %rec is also a hash) usually comes from the input from a form. Take a look at sub parse_form in db.cgi to see how the %in hash is built. The query subroutine uses the %in hash to do the searches and to know where it is in the list.

When you display the "long" record, all of the search parameters are already in the %in hash -- that's what it searched on to come up with the record. $in{'mh'} is the maximum number of hits on a page. When you go to the "long" record, this is set to 1, so that only one record shows up. $in{'nh'} isn't really the number of hits. It's the page number of the hits. With the "long" record display, since $in{'mh'} = 1, $in{'nh'} is equal to the record number. But if you go from page to page in the short display, you'll see that, if $in{'mh'} = 10, record 11 will be on the second page -- $in{'nh'} = 2. (Whew! Didja follow all of that? Smile )

What I have in mind is tricking the script into thinking it has received input from a form, by setting the $in{'mh'} and $in{'nh'} values by hand, bypassing sub parse_form and going straight to sub query. (It helps me to anthropomorphize the script. Smile )

So, after all that, what you would do in html_record_long is, after you print out your record and the stuff for the top of your other column,

Code:
|; # to close off your print statement
$in{'mh'} = 5;
$in{'nh'} = 1;
my ($status2,@hits2) = &query('view');
my ($numhits) = ($#hits2+1) / ($#db_cols+1);
$i = 1;
for (0 .. $numhits - 1) {
%rec2 = &array_to_hash($_, @hits);
$long_url = $ENV{'QUERY_STRING'};
$long_url =~ s/\&nh=\d+//;
$long_url =~ s/\&mh=\d+//;

$long_url = "$db_script_url?$long_url&nh=$i&mh=1";
print qq|<P>$rec2{'Date'}<BR>
<a href="$long_url">$rec2{'Title'}</a>
|;
++$i;
}

and then all the stuff you need at the end of your page.

If you want to get fancy and not have a link to the current page in your list use

Code:
print qq|<P>$rec2{'Date'}<BR>|;
unless ($rec2{$db_key} eq $rec{$db_key}) {
print qq|
<a href="$long_url">$rec2{'Title'}</a>
|;
}
else { print $rec2{'Title'}; }

Clear as mud? Wink


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





Quote Reply
Re: Short/Long list mod need help In reply to
Yippieee,

I am off to go experiment.. You are so wonderful JPDeni, you can't even imagine how giddy I am right now.

I am sure that this routine is going to help me big time to get a better grip on (hash's).

Thank You! soooo much. Wink



------------------
Larry "NgtCrwlr" Mingus
www.makeitsimple.com