Gossamer Forum
Home : Products : DBMan : Installation :

List All on the Index Page

Quote Reply
List All on the Index Page
I am setting up a database of final theses, for which I would like to display the titles of all available topics directly on the index page, with links to the complete descriptions.

Knowing little about Perl, I have tried and played with a few lines of code from the html_view_success subroutine. I came up with:

for (0 .. $#db_cols) {
%tmp = &array_to_hash($_, @hits);
print qq|<A HREF="">$tmp{'Titel'}</A><P>\n|;
}

but (as I more or less expected) that doesn't work. Could one of you Perl gurus tell me how to do this?

Thanks in advance,
Alexander
Quote Reply
Re: List All on the Index Page In reply to
So what you are looking for is a list off all the topics in your database where topic is just the name of one of the fields?

You could try something like this:

print qq~
<form action="$db_script_url" method="GET">
<input type=hidden name=db value="$in{'db'}">
<input type=hidden name=uid value="$in{'uid'}">
Get Thesis: ~;
print &build_select_from_db ('Thesis', '');
print qq~
<input type=submit name="view_records" value="Go get it!">
</form>
~;

Give that a shot. Basically what &build_select_from_db does is it makes a list of unique entries in one column of the database.

Hope this helps,

Alex
Quote Reply
Re: List All on the Index Page In reply to
Hi Alex,

thanks for the code snippet. I was thinking of something different, however. What I`d like to do is display all titles in plain text (encapsulated by an A HREF pointing to the full description), not as a fancy popup menu. This would require going through all lines in the database and outputting the title fields. Checking for uniqueness is not an issue, since there will only be about a dozen theses in the database at any given time.

I know, using DBMan is kind of overkill for this project, but a) I already use the engine for our publication database (which will hold several hundred records), and b) it allows the institute staff to add the theses themselves without allowing them access to the server and teaching them HTML.

If you want to take a look at what it looks like now (using your popup menu), point your favorite browser at:
http://www.tu-bs.de/cgi-ibvt/db/db.cgi?db=arbeiten&uid=default

As usual, any help would be greatly appreciated.

so long
Alexander
Quote Reply
Re: List All on the Index Page In reply to
I too, am looking for a way to have a links created to the full detail of the entry.

For example, I would like the script to create links for all of the entries..
database entry #1
database entry #2
database entry #3

In the sub html_record

I was able to put in:
<a href="$db_script_link_url&view_records=1&Name=$rec{'Name'}">$rec{'Name'}</a>

...which works, but it also shows the full detail along with each link.

I just want a bunch of links created that I can click on to see the full detain of each link. Any help would be greatly appreciated.



[This message has been edited by Katana Man (edited January 10, 1999).]
Quote Reply
Re: List All on the Index Page In reply to
I forgot something in the above post. After

%rec = &array_to_hash($_, @hits);

add

$Title = $rec{'Title'}
$rec{'Title'} =~ s/ /+/g;
print qq|<a
href="$db_script_link_url&Title=$rec{'Title'}&view_records=1">$Title</a>|;
}


If there are any spaces in your titles, what I gave you before won't work. Spaces have to be converted to "+"s if they're going into a URL. Sorry 'bout that.




------------------
JPD
Quote Reply
Re: List All on the Index Page In reply to
Thanks JPDeni!

This must be a hobby for you, because you enjoy helping people out. Thank you.

My DMBan is shaping up nicely.

While I have your attention, got any idea on how to back up the database file every so often? Or have the script pump the data out to 2 files, but only modify 1 ?
Quote Reply
Re: List All on the Index Page In reply to
You were really close, just needed a little more.

For all titles in the database to be listed on the home page, add the following to sub html_home:

$in{'Title'} = "*";
$in{'sb'} = [the number of the Title field] # if you want the results sorted
&query();
my (@hits) = @_;
for (0 .. $numhits - 1) {
print "<P>";
%rec = &array_to_hash($_, @hits);
print qq|<a href="$db_script_link_url&Title=$rec{'Title'}&view_records=1">$rec{'Title'}</a>|;
}


If you want to have the results of a search return in an index, there's more discussion of this elsewhere in the forum under something like "short vs detailed display." Look for username "Norm."





------------------
JPD
Quote Reply
Re: List All on the Index Page In reply to
You're welcome. Smile It's sorta become an obsession lately!

Backing up the db file? Well, you could possibly use cron, but I don't know anything about it. Do a search for cron in the archives.

No idea about how to implement the second thing. That would be major, though, I think.

Glad I could help before. Wish I could with this.



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