Gossamer Forum
Home : Products : DBMan : Customization :

DBMan as an ENCYCLOPEDIA???

(Page 1 of 2)
> >
Quote Reply
DBMan as an ENCYCLOPEDIA???
Does anyone here use Dbman as a database for an Encyclopedia? For axample "The Encyclopedia of Pop music".

How do you cope with the long fields?
Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
Not to my knowledge....

All you have to is change the value for 255 in text box fields to larger numbers like 50,000 in the fields located in the %db_def hash in the default.cfg file.

Be aware that if you database is going to be larger than 1 MG, you should consider using the MySQL version of DBMAN, which a new upgrade will be released soon, and least that is what I've read in other Gossamer Threads forums.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums


[This message has been edited by AnthroRules (edited March 11, 2000).]

[This message has been edited by AnthroRules (edited March 11, 2000).]
Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
Hmmm... you been looking over my shoulder??? Just kidding. One of my DBs is strctured like this: each record is the pointer to a text file which would contain the acutal article... this allows me the flexibility to sort, categorize, etc, etc, without the overhead of the text article in the DB.

------------------
The Immuatable Order of Modding
-=-=-=-=-=-=-=-
1. Read the FAQ, 2. Search the board, 2a. Search the board again, 3. ask the question, 4. back-up, 5. experiment, 6. rephrase question (or better yet, post solution to original question)

Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
I've been trying to do something simelar, unfortually I'm no perl expert......

What I'd like was a way to make dbman print the contents from the different fields to a txt file, and then display that txt file using ssi when the post is called after a search. I've searched the forum and found some threads about printing to files etc. but adjusting them is way over my head.

I know this seems like a lot to ask for, but then again I have no expectations.

Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
You wouldn't need to use an SSI to display the .txt file. DBMan could do that on its own, as long as it knows where to look and which file to display.


JPD
Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
As far as I can tell that makes it "les thard" to code, but I'm afraid it's still way past be knowledge. I tend to manage "small" code adaptions and keep learnig. This idea however is a long way into the future for me to able to manage.

I would be incredible greatfull if someone gave it a shot, but as I said before theres no expectations...

Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
Can you give me a little more detail of what you have in mind?

JPD
Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
I'll try

1 when a a post is added the fields are exported to a txt file and only the title, category and reference to the correct txt file gets stored in the db file. This should keep the db file way under 1 mb even as the database grows.

2 when someone views the post dbman grabs the field contents from the txt file.

In addition I also invision using a bunch of the incredible mods already outhere.

Of course the best thing would be the sql version, but sometimes (as for me) money get in the way of happines

Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
This could definitely be done.

You would want to set up your .cfg file to include only those fields that would be actually in the database. It would probably be best to set up a counter for the $db_key field. You would not be able to use the autogenerate feature.

Define a variable in your .cfg file--

$save_text_dir = '/path/to/text/file/directory'; #Not a URL! No trailing slash!!

In sub html_record_form, include all of the fields for the .cfg file, plus add other fields for the information you're going to be adding to the .txt file.

Hmmmmm. I just thought of a problem. Modifying.

What fields are you going to want to add to your .txt file?


JPD
Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
wow

After seeing your work all over the forum I should have suspected that you would be way a head of me. I am actually at the drawingboard.

be back in a few minutes.

by the way, you're the queen and undisputable ruler the dbmaniverse

Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
After a quick thought I would say I'd be wanting the following fields :

title (textfield)
teaser (textaerea)
story (textaerea)
photo (for your fantastic upload mod)
author (textfield)

these would be in addition to

id (textarea) keyfield and dbman keeping the count.

water

Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
Laugh Thank you!

I actually have done something similar to this in one of the databases I created for myself. I didn't have the script write to the .txt file, but I had it pull text from a .txt file and display it.

The thing is that, in order to modify anything, you'll need to pull the values from the .txt file and put them back into the form. If you're going to just have the long text in the external file, it wouldn't be too hard to insert it into a textarea. But if you're going to have several fields, we'll need to work out a way for the code to be able to parse the data from the .txt file.


JPD
Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
You're more than welcome

just the long text (story field) would do the job.

water

Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
Okay. That would be fine then.

Where was I? Oh, yes.

Add a textarea field to sub html_record_form and call it text. (Just make sure you don't have a field called "text" defined in your .cfg file.) Also, remember the correct way to define a textarea, which is different from a regular field. If you need help with that, just ask.

In sub add_record, after

close DB; # automatically removes file lock

add

Code:

open (TEXT, ">$save_text_dir/$in{$db_key}.txt") or
&cgierr("error in add_record. unable to open text file
$save_text_dir/$in{$db_key}.txt\nReason: $!");
print TEXT $in{'text'};
close TEXT;
After you get this done, let me know. I don't want to go any further until you are sure that this works. Add a record and check to be sure that a file was created in your text directory, with a name that matches the key value of your record. Once we know that is working all right, we can display it.

BTW, you can put any html formatting that you want to in the text area.

Don't do any fancy formatting of the page yet. That can come after you put all of your mods in.


JPD
Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
You just did your magic again.......


:water
Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
It's really just a matter of being familiar with the script. I do lots of copying and pasting from the original DBMan files and then switch them around to do what I want.

JPD
Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
It's working, but I've found to (small) possible errors

1 the contents of the text textarea is still written to the correspondig field in the db file.

2 I missed a required field (not text) while trying a post, and when dbman returned with the error message the contents of the texttextarea was erased and had be rewritten.

btw, I've also added the archive mod and a short/long/longer mod and all is well.


:water
Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
In Reply To:
the contents of the text textarea is still written to the correspondig field in the db file.
Then you probably have a field defined in the .cfg file that has the same name as the textarea field. You can't do that.

In Reply To:
I missed a required field (not text) while trying a post, and when dbman returned with the error message the contents of the texttextarea was erased and had be rewritten.
To take care of that now (I was going to address it later), set up your textarea like

<textarea name="text" rows="5" cols="40" maxlength="50000">$in{'text'}</textarea>



JPD
Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
It's morning again in norway.....

You've delivered the goods once more. You're right on the account of me not removing the field definition from .cfg, stupid of my to have over looked that. I took it out at first, but then put it back to sort out another problem with the database. Afterwoods I forgot all about it, thats a lesson for me for doing this when I should have been sleeping.

I'm more than happy for the mod'ing to take the steps in the correct order, I just got a bit carried away.



:water
Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
That's okay. Smile (I really should be going to bed. It's almost 3am here on the Pacific Coast of the US.)

So you have it saving the .txt file in the correct directory and not in the .db file, right? Yay!

Now we need to print out the .txt file.

You said you have a short/long/longer display. You'll probably want to print the .txt file in your "longer" display.

At the beginning of the subroutine for the display where you want to print out the .txt file, after

my (%rec) = @_;

add

Code:
open (TEXT, "<$save_text_dir/$rec{$db_key}.txt") or
&cgierr("error in add_record. unable to open text file
$save_text_dir/$rec{$db_key}.txt\nReason: $!");
@text = <TEXT>;
close TEXT;

$rec{'text'} = join "",@text;
At this point, the entire text from the text file will be in the variable $rec{'text'}. You can use it to print out the text anywhere you want to.

If this works all right, the next step is to allow you to modify the .txt from the form. And then you'll be done! Smile

Go ahead and add the text I gave you earlier for putting the text back into the textarea when you have an "add failure." Test that out, too, to make sure it works.


JPD
Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
Yep, it's saving, and only to the txt file Smile

In Reply To:
Go ahead and add the text I gave you earlier for putting the text back into the textarea when you have an "add failure." Test that out, too, to make sure it works.
I did that last night, sorry I forgot to tell you, and it works perfectly.

We're not so fortunate with the rest of the code however, it procuced the following error :
Code:

CGI ERROR
==========================================
Error Message : error in view_record. unable to open text file
/inetpub/wwwroot/txt/2.txt
Reason: No such file or directory
Script Location : C:\Inetpub\wwwroot\cgi-bin\dbman\test\db.cgi
Perl Version : 5.006
Setup File : r.cfg
User ID : admin
Session ID : admin.95882312695994


dispite the error message both directory and file are there, and the paths are correct both in the .cfg file and here in the error message.

btw, Just in case you wonder about the error message, I changed add_record to view_record to easier seperate them from each other.



:water
Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
Just letting you know i am following this thread with my mouth watering! Very excited about the possibilities!

How would a search function work? Could it search the txt files?

Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
your mouth is not alone.....


:water
Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
hotwheel, I'm afraid that the search will not work in the .txt fields. It might be a good idea to add a field to the .cfg file with keywords that people might want to search on, but are not in the other fields. Just make sure you *don't* call it keyword. That would be a bad thing. Smile

water, try setting

$save_text_dir = 'C:/Inetpub/wwwroot/test';

It may need the entire path in order to find the files.

I just thought of another thing, which probably isn't a factor for you. Unix users would need to chmod their text directory to 777.

JPD
Quote Reply
Re: DBMan as an ENCYCLOPEDIA??? In reply to
I'm sorry to say that C:/inetpub/wwwroot/txt was not the medicine, I've also triesd using the url, and got the same error.

Just to make sure I've accessed the url http://localhost/txt/2.txt and the file was diplayed in the browser.


:water
> >