Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Long + Short Display

Quote Reply
Long + Short Display
Hi.
I'm a bit new in SQL but is it still possible to have a "long/short" display using DBman SQL? If so, how?

thanks a bunch!!

Quote Reply
Re: Long + Short Display In reply to
Absolutely you can,
- Default template: Select Short or Long option in search form.
- Change default template: You should change search_results.html:
<%Loop%>
<%if detail%>
Field 10: <%Field 10%>
Field 11: <%Field 11%>
<%else%>
Field 1: <%Field 1%>
Field 2: <%Field 2%>
.....
<a href="db.cgi?db=<%db%>&do=search_results&detail=1&ID(primary key)=<%ID%>&ID-opt==">Detail</a>
<%endif%>
<%endloop%>

911.

Quote Reply
Re: Long + Short Display In reply to
Yes, even your version is 1.0 or 1.02 you can adopt this long/short hack.

Just follow the instruction on the hack files.
Download the files from the resources center, I think it's under DBMAN (not DBMANSQL)

You can also adopt newest post hack, and send to friend hack, I use them on my db.

good luck

__________________________
http://anteromas.com
Trading Resources
Quote Reply
Re: [911] Long + Short Display In reply to
In Reply To:
Absolutely you can,
- Default template: Select Short or Long option in search form.
- Change default template: You should change search_results.html:
<%Loop%>
<%if detail%>
Field 10: <%Field 10%>
Field 11: <%Field 11%>
<%else%>
Field 1: <%Field 1%>
Field 2: <%Field 2%>
.....
<a href="db.cgi?db=<%db%>&do=search_results&detail=1&ID(primary key)=<%ID%>&ID-opt==">Detail</a>
<%endif%>
<%endloop%>

911.

Ok so I got that working.

My question is what is the format type long short used for?
I see the listing, but no link for details. Is this normal? How do I modify short listing to show different values and maybe a link to details...

I was wondering if I could use this fm=long/short instead of modifying all my templates....

Thanks
Quote Reply
Re: [Hank] Long + Short Display In reply to
Hi,

Let replace the subroutine below in HTML.pm

sub generate_search_results {
#----------------------------------------------------------------------
my $tags = GT::Template->tags;
my $record = $tags->{results}[$tags->{row_num}-1];
if ($tags->{home}->{cgi}->{fm} eq 'short') {
my $num_cols = $tags->{home}->{cgi}->{num_cols} || 3;
my $output = '<table border=1 cellpadding=0 cellspacing=0><tr><td><table border=0 width=500>';
my $cols = $tags->{home}->{db}->cols;
my @ordered_cols = $tags->{home}->{db}->ordered_columns;
my @pk = $tags->{home}->{db}->pk;
my $pk_url = ($tags->{home}->{cgi}->{sid})? "sid=$tags->{home}->{cgi}->{sid}" : '';
foreach (@pk) {
$pk_url .= ($pk_url)? "&$_=$record->{$_}&$_-opt==" : "$_=$record->{$_}&$_-opt==";
}
my $count;
foreach (@ordered_cols) {
my $title = $cols->{$_}->{form_display} || $_;
$output .= qq~<tr ><td width='30%'><font face='Tahoma,Arial,Helvetica' size=2>
$title </td><td width='70%'><font face='Tahoma,Arial,Helvetica' size=2>
$record->{$_}</font></td></tr>
~;
$count++;
last if ($count == $num_cols);
}
$output .= "<tr><td><a href='db.cgi?db=$tags->{home}->{cgi}->{db}&do=search_results&$pk_url'>Details</a></td></tr></table></td></tr></table>";
return $output;
}
else {
my $output = $tags->{home}->{disp}->display ( { mode => 'search_results', values => $record } );
return $output;
}
}
Hope that helps.

Cheers,
TheStone.

B.
Quote Reply
Re: [TheStone] Long + Short Display In reply to
Thanks works nicely...
How would I add addittional fields for the short display?.... found it, just change the 3 to whatever... :)

Last edited by:

Hank: Nov 9, 2001, 11:10 AM
Quote Reply
Re: [Hank] Long + Short Display In reply to
Hi,

Actually, you can send num_cols to the browser:
db.cgi?......&do=search_results&fm=short&num_cols=whatever

Cheers,
TheStone

B.
Quote Reply
Re: [911] Long + Short Display In reply to
Quote:
Absolutely you can, - Default template: Select Short or Long option in search form.
I am using 2.02 - where do you find the above option?

Quote:
Change default template: You should change search_results.html:
<%Loop%>
<%if detail%>
Field 10: <%Field 10%>
Field 11: <%Field 11%>
<%else%>
Field 1: <%Field 1%>
Field 2: <%Field 2%>
.....
<a href="db.cgi?db=<%db%>&do=search_results&detail=1&ID(primary
key)=<%ID%>&ID-opt==">Detail</a>
<%endif%>
<%endloop%>
Do I use the above in lieu of the <%Dbsql::HTML::generate_search_results%> statement in search_results.html?

Thanks.

easy does it
Quote Reply
Re: [Bearwithme] Long + Short Display In reply to
Hi,

In Reply To:
I am using 2.02 - where do you find the above option?
You can choose Long/Short format option in search form.

In Reply To:
Do I use the above in lieu of the <%Dbsql::HTML::generate_search_results%> statement in search_results.html?
That right, if you want to customize your template.

Cheers,
TheStone


B.

Last edited by:

TheStone: Nov 12, 2001, 10:15 AM
Quote Reply
Re: [TheStone] Long + Short Display In reply to
This thing is cool Cool

I am able to do lots of different things with this template thing...

Couple of questions about this detail...
I am using this link to details
Code:
<a href="db.cgi?db=<%db%>&do=search_results&detail=1&ID=<%ID%>&ID-opt==">

What does the detail=1 mean? I am trying to give different users a different details, and I can do it hard way, but this detail=1 is interesting, if it does what I think it does... Could not find any help on this.

I also have this on the top of the search results:
Code:
<%include header.html%>
<%if detail%>
<%loop results%>
<%include record_detail.html%>
<%endloop%>
<%else%>

and again detail? what variable is that, or is that a htmlpage.

I forgot where I copied this stuff, but its working great.... just need an answer what is the detail here for?
Quote Reply
Re: [TheStone] Long + Short Display In reply to
Quote:
That right, if you want to customize your template.

Thanks Stone, I got it working - I can always depend on your answers.


easy does it
Quote Reply
Re: [Hank] Long + Short Display In reply to
Hi Hank,
In Reply To:
This thing is cool
Thanks Laugh

In Reply To:
What does the detail=1 mean?
That is avariable to know when it will show the detail page. You can use whatever, but make sure:
<%if whatever%>
....
<%include record_detail.html%>
...
<%endif%>

In Reply To:
I am trying to give different users a different details, and I can do it hard way, but this detail=1 is interesting, if it does what I think it does... Could not find any help on this.

For instance, you can find follow the instructions:
1. Add a field (Eg. tpl_detail) in your User table (goto Editor - Users - Customize ...), that field will be saved the detail pages. (Eg. Record_detail1.html, record_detail2.html...)

2. Add tpl_include into Global template:

sub {
my $tags = shift;
my $template = $tags->{template} || $CFG->{template};
my $pg = $tags->{tpl_detail};
my $root = "$CFG->{admin_root_path}/templates/$template";
GT::Template->parse ( $pg, $tags, { print => 0, root => $root } );
}

3. Modify search_results.html file:
<%if detail%>
<%loop results%>
<%if tpl_detail%>
<%tpl_include%>
<%else%>
<%Dbsql::HTML::generate_search_results%>
<%endif%>
<%endloop%>
<%endif%>

Cheers,
TheStone

B.

Last edited by:

TheStone: Nov 13, 2001, 10:41 AM
Quote Reply
Re: [TheStone] Long + Short Display In reply to
Thank you much!

Make sense... check what I did, (It works, but not sure if this is right thing to do for security)

Quote:
<%if AccessLevel eq 'Level1'%>
<%loop results%>
<%info1%> <%info2%>
<%endloop%><%endif%>

<%if AccessLevel eq 'Level2'%>
<%loop results%>
<%info1%> <%info2%> <%info3%>
<%endloop%><%endif%>

This what I got on record_detail page...
Only thing I added was setup AccessLevel enum on usertable....

Works fine but I might have missed something (security wise)...