Gossamer Forum
Home : Products : DBMan : Customization :

Short Long 1 record goest to long, 2 or more to short.

Quote Reply
Short Long 1 record goest to long, 2 or more to short.
 
I'm using the short/long mod .. When I view a single record via search or any other situation that results in a single record, it automatically goes to "display long record" even if there is only a short display for this record.

I'm pretty sure the quirk is in sub view_success, and specifially the routine that measures maxhits .. But I can't seem to find a solution. I've looked at the shorter/short/long threads and applied that, no avail. Now I'm back at short/long default ..

I'm not sure this can even be solved. The logic required to display 1 record and more than 1 would cause a catch 22 loop ( I seem to find these alot ) ..

If there is no way to do this, the solution would be to have the long record detect itself ( ie, everything goes to the long display.. and sas if $rec('long_desc') do my long code, else do my short code.

I bet the latter would be the easies thing to do, I'm just curious if anyone has solved this yet another way?

------------------
The Crowe crowe@charter.net
www.lit.org Links Engine for Writing on the net!



Quote Reply
Re: Short Long 1 record goest to long, 2 or more to short. In reply to
Me again.

I seem to end up talking to myself on the board alot Wink

I applied my second suggestion and it worked. I beleive this is probably the easiest and safest way to do it. If anyone did have the first idea worked out though, I'd be interested in seeing how it worked.







------------------
The Crowe crowe@charter.net
www.lit.org Links Engine for Writing on the net!



Quote Reply
Re: Short Long 1 record goest to long, 2 or more to short. In reply to
I'm not really clear on what you did Smile, but if it works, that's all that matters.

What I think you did, in effect, was set a switch for long and short displays. That's great.

Don't worry about talking to yourself. I do it all the time! Smile


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





Quote Reply
Re: Short Long 1 record goest to long, 2 or more to short. In reply to
Would you be so kind as to post what changes you made to make it work.

With all new databases that have few records this does come up often. Only showing the long display unless there are more then 1 listing.

I'd really like to see how you modified this to default to the short display regardless.

Thanks in advance Smile
Quote Reply
Re: Short Long 1 record goest to long, 2 or more to short. In reply to
 
Well, here is the gist of what I did.. I modiefied sub html_record_long to this


if ($rec{'long_desc'}) {
Long display here..

}

else {
&html_record;

}[/code]
I have a field that I base it on. < long description hence the long_desc .. > So if it detects that the long description is there, print the long one.. If not, don't bother and call the regular short display.

I think this gives you the info you need to apply it to yours. I've seen your posts, I know you can handle it! .. If you need to see the any of my code ( or all of if for that matter ) .. i'd be happy to make a zip file or txt files for everyone to see..

My next step is to create the last X records into a text file ( cause SSI causes to many problems ) and last X headlines text file so I can include them in my start page.

Crowe

------------------
The Crowe crowe@charter.net
www.lit.org Links Engine for Writing on the net!



Quote Reply
Re: Short Long 1 record goest to long, 2 or more to short. In reply to
Doah! Actually, That didn't work exactly either, I had to cheat it a bit further Forgot about that ( I'm beat, been modding this thing for a week now! )..

My long and short are pretty close in looks, so what I did was detect if there was a long description.. if so, diplay it in the descrition instead of the short display.. Just like the code I posted before but put it at the point where you want to test for content..

The problem with calling &html_record is the same problem we are facing with the maxhits == 1 .. that code HAS to be that way to show a single record, otherwise do the loop. I can't find a way around it. So no matter what, when you call a html_record subroutine and it makes its way to view_success, we hit the old maxhits == 1 ( like I said, I can find these loops like no body's business! ) ..

At any rate, Since I'm managing news posts, I found it easy to just "if detects long_desc, display long_desc, else display short_desc.

BUT, the other solution is to build you're sub html_long with this test, but instead have

if long_desc { long display code }
else { short display code }

Psuedo code, of course ..

This would make the routine a little bigger and less dynamic. But the short display code from your &html_record could just be cut and pasted here. Kind of a pain in the butt, but I suppose you could just do all this with one routine really as apposed to the short/long mod. This is practical if you know a certain field will determine if a record will have a long view or not. And in most cases, you will Wink

If any of this isn't clear, just yell and I'll help you get yours working.

------------------
The Crowe crowe@charter.net
www.lit.org Links Engine for Writing on the net!



Quote Reply
Re: Short Long 1 record goest to long, 2 or more to short. In reply to
You're right, it gets confusing up there. I HAVE SOLVED THIS!! But first, I will explain.
What kind of mayhem I've been up to!

I am using the short/long mod. In my database, people can post news. Either a short blurb, with which there should NEVER be a long view of. Or, if they DO enter a long description of the news, the long version should display.

This works like a champ *ONLY IF* more than one record comes up in a search. However, If ONLY ONE record shows up, it displays the long record regardless. This is because of how sub view_success detects what do to.

I'm sure there are several ways to fix this problem, but my solution is pretty easy.

All you have to do is make your short display like you want. Then, make your long display like you want it to be.

Now, the mod to make this all work. In sub html_long , add if else code like this

<psuedo code>

if long_desc do long code

else do short code

</pseudo code>

Then just copy/paste your sub html_record to the short code.

This is a rare occurance, since 99% of the time you'll get more than one result in a search. But to be a perfectionist like I am, I had to solve this problem.

There are some basic logic problems with doing this other ways, but I'm sure there are other ways.. This way is pretty fast and very easy.

When I get home tonight, I'll pust my code for this!
















------------------
The Crowe crowe@charter.net
www.lit.org Links Engine for Writing on the net!



Quote Reply
Re: Short Long 1 record goest to long, 2 or more to short. In reply to
I'm lost. Smile

Can you start over, explaining exactly what you want to achieve? (To quote a line from the movie "Philadelphia": "Explain it to me like I was a three-year-old." Smile )

From what you've written, it seems that you want the determination of whether a long or short version of the record is displayed to be based on the value of a field in that record. I don't think that can happen. The records returned from a search must all be either long or short displays.

You can determine whether or not certain fields will be included in a display, based on the value of those fields or other fields. Is that what you want?


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





Quote Reply
Re: Short Long 1 record goest to long, 2 or more to short. In reply to
Okay. Now I see. (It really does need to be explained to me as if I were a three-year-old. Smile )

I would like to see your code. I'm always happy when people take the mods another step.


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





Quote Reply
Re: Short Long 1 record goest to long, 2 or more to short. In reply to
I think I'm cursed Smile

When I detect if the FIELDS are there like

if long print long
else print short it works

As long as I use the all the rest of the code the same, but when I do and IF / ELSE with ALL the codes , meaning to different displays, thats when a "SIGNLE" record will show up with nothing but a header footer.

www.fragdot.com/staff/db.cgi?db=review

Feel free to log in and look around. user guest/guest.

Also, here are the core text files I use
www.fragdot.com/staff/format.txt

www.fragdot.com/staff/review.txt

Let me know what you make of this quirk.. Am I blind? missing something? Doing something wrong? Smile



------------------
The Crowe crowe@charter.net
www.lit.org Links Engine for Writing on the net!





[This message has been edited by Crowe (edited March 22, 2000).]
Quote Reply
Re: Short Long 1 record goest to long, 2 or more to short. In reply to
This one's gonna take some time and hubby needs the phone line. I'll be back! Smile


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





Quote Reply
Re: Short Long 1 record goest to long, 2 or more to short. In reply to
I'm having a real hard time reading the text on your search results because of the colors. I can't tell where the links are. (Maybe your target audience is much younger than I am and they have better eyesight. Smile )

Let me go through it again to be sure I know what you're doing.

If more than one record is returned from a search, you only want links for a long display if there is something in the "long_desc" field.

If there is nothing in the "long_desc" field, even if there's only one record returned, you want the short display, with no link to a long display.

Yes?


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





Quote Reply
Re: Short Long 1 record goest to long, 2 or more to short. In reply to
 
Sort of Wink

Here is what I want to happen.

For more than one hit, display short record.
If a long_desc is in the record, link to the long record.

If A SINGLE record is found, Check if a long desc is present, if so, present the long code, if there is NO long desc, print the short code.

At present, Any SINGLE record found prints LONG CODE only.

Hope that helps Wink

------------------
The Crowe crowe@charter.net
www.lit.org Links Engine for Writing on the net!



Quote Reply
Re: Short Long 1 record goest to long, 2 or more to short. In reply to
It's going to take some studying of your files to figure out what's going on for certain.

As something to try, instead of

Code:
if ($rec{'long_desc'})

try

Code:
if ($rec{'long_desc'} gt "")

See if that does you any good. Try it in html_record (with the short display) first to see if you can get rid of the "Read More" link for the ones that don't have long_desc.


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





Quote Reply
Re: Short Long 1 record goest to long, 2 or more to short. In reply to
That really isn't a problem. That already works.

Everything works EXCEPT single record display. It always goes to long desc, even if there isn't one.

Any attempt to correct this results in a header and a footer, but no record Wink


------------------
The Crowe crowe@charter.net
www.lit.org Links Engine for Writing on the net!



Quote Reply
Re: Short Long 1 record goest to long, 2 or more to short. In reply to
I see that you commented out

Code:
#if ($in{'headlinetolong'} == 1) { &html_record; }

#else {

in your file.

Try changing that to

Code:
unless ($rec{'long_desc'}) { &html_record; }

else {

and don't forget to put back in the closing bracket for your "else" command.

If that doesn't work, I have another idea.


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





Quote Reply
Re: Short Long 1 record goest to long, 2 or more to short. In reply to
 
Bam, Bang, Pow! You got it! Smile

Wonderful job. You're alright despite what everyone else said <grin>

Thank you very much. I'm sure i'll break something else! .. lol.

------------------
The Crowe crowe@charter.net
www.lit.org Links Engine for Writing on the net!



Quote Reply
Re: Short Long 1 record goest to long, 2 or more to short. In reply to
Whew! One down, a zillion to go.

You really were on the right track before. You just didn't know it.



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





Quote Reply
Re: [JPDeni] Short Long 1 record goest to long, 2 or more to short. In reply to
Greetings All,

I've been looking for an easy solution to the problem described in this thread and others: Using the long/short display mod, how to display the short results even when only one record is returned. I may be missing something, but this seems to work for me:

In html.pl, subroutine html_view_success

change

if (($db_total_hits == 1) || ($maxhits == 1)) {
&html_record_long(&array_to_hash(0, @hits));
}

to

if ($maxhits == 1) {
&html_record_long(&array_to_hash(0, @hits));
}

.. or am I missing something?
Tim Ault
Oxford UK
Quote Reply
Re: [timbo] Short Long 1 record goest to long, 2 or more to short. In reply to
Your posted solution should work to:

How to go directly to short display if only 1 record

but i think Crowe was doing something a little more complex and basing it on the contents of a field as to the display which would be shown.

Unoffical DBMan FAQ
http://redundantcartridge.com/dbman/