Gossamer Forum
Home : Products : DBMan SQL : Discussion :

How include data from another table?

Quote Reply
How include data from another table?
I want to include a "search-result list" from another table in search_results.html.

I am using DBMAN Sql 2.0.3

The databse which shall show the information is called "name". In the search results for this table data from the table "books" shall be shown.

The usual way of doing this when using ssi is:
<!--#include virtual="/db/db.cgi?db=books&do=search_results&details=0&category=barnets navn"-->

How is this done in the template file for this table?


Kjetil
..........................
Kjetil Palmquist
www.svanger.com

Last edited by:

kjetilpa: Mar 11, 2002, 8:46 AM
Quote Reply
Re: [kjetilpa] How include data from another table? In reply to
You can do something like that by using the globals in Dbsql 2.0.3. Just add the sub below to your globals:

Code:
include1 => sub {
my $tags = shift;
$tags->{home}->{cgi}->{db} = 'books';
$tags->{home}->{cgi}->{do} = 'search_results';
$tags->{home}->{cgi}->{details} = '0';
$tags->{home}->{cgi}->{category} = 'barnets navn';
my $results = $tags->{home}->search_results;
return $tags->{home}->print('search_results.html',$results);
}



then add a tag like <%include1%> into your template file where you want to display the include results. You can also copy search_results.html to another name and change the name above (in blue)


Cheers,
jean@Gossamer Threads
Quote Reply
Re: [jean] How include data from another table? In reply to
The above code gave this result where the search-results should be displayed:

include_books => sub { my $tags = shift; $tags->{home}->{cgi}->{db} = 'bokkilden_svanger'; $tags->{home}->{cgi}->{do} = 'search_results'; $tags->{home}->{cgi}->{details} = '0'; $tags->{home}->{cgi}->{category} = 'barnets navn'; my $results = $tags->{home}->search_results; return $tags->{home}->print('search_results.html',$results); }

I did exactly as you wrote. What is wrong?
..........................
Kjetil Palmquist
www.svanger.com

Last edited by:

kjetilpa: Mar 12, 2002, 12:17 PM
Quote Reply
Re: [kjetilpa] How include data from another table? In reply to
Hi,

You should add only the code sub {...} into the Description text area and include_books should be added to Code column (in Admin >> Template Globals) . After that, you can have a new tag <%include_books%> in your templates.

Cheers,

Jean@Gossamer Threads
Quote Reply
Re: [jean] How include data from another table? In reply to
When doing this no result is displayed. The webpage is not displayed at all.

Any suggestions on how to solve this?

Kjeti°
..........................
Kjetil Palmquist
www.svanger.com

Last edited by:

kjetilpa: Mar 14, 2002, 11:59 AM
Quote Reply
Re: [kjetilpa] How include data from another table? In reply to
Hi,

Could you send me a private message contains your Dbsql admin information ? I'll take a closer look and will help you to fix it.

Cheers,

Jean