Gossamer Forum
Home : Products : DBMan : Customization :

Hack, hack, hack. Help! (+ Feature Request)

Quote Reply
Hack, hack, hack. Help! (+ Feature Request)
I moved to the long/short mod. It works very well. There is still, however something missing from the whole thing. Consider this post in two parts:

First:
Can someone offer suggestions on how to go about creating the following, and

Second:
Please consider these feature requests, as I've read requests for these sort of things a few times here.

Multiple templates/layouts:
Using the short/long mod, I'm able to view a record in a list, and as it's own entity. Excellent.How can I now create an admin layout in the same way. I want my database to show list records, display records and admin data entry/modification in different ways.

The short and long are obvious, but the separate data entry layout for admins means that I can have all the fields, and many won't show up under the user search. I can have upload buttons for images, but the record full view shows only the image, and neither shows up on the records search. (Is all of this clear?)

Randomizing records:
I want to be able to create a "record of the day", or a randomly displaying record using a certain URL. For example, I'm creating a real estate database, and I want my user to see "The house of the day" by clicking on a regular link.

So!

a) How can I create a separate admin-entry/user-search display while keeping the excellent long/short mod.

b) Does anyone have a solution for creating a random display of records based on a link?
Quote Reply
Re: Hack, hack, hack. Help! (+ Feature Request) In reply to
Frank,

You can incorporate into both your form and your record view the fields that you want only shown to the admin user or even have some for registered and the rest displayed to everyone.

In your different views you can use an "if" statement to determine the users rights and deliver only the content that you want them to see.
For example:
Code:
print qq|
<tr> this row will be shown to everyone </tr>
|; if ($per_mod) { print qq|
<tr> this will be shown to registered users with modifications rights </tr>
|;} print qq|
<tr> this row shown to everyone </tr>
|; if ($per_admin) { print qq|
<tr> this shown only to admin </tr>
|;} print qq|
<tr> shown to everyone etc... </tr>
.
.
.
|;

Hope that helps with your first issue. Sorry, I can't help with the random select issue.

B/R
Steve


[This message has been edited by StevePlant (edited September 24, 1999).]

[This message has been edited by StevePlant (edited September 24, 1999).]
Quote Reply
Re: Hack, hack, hack. Help! (+ Feature Request) In reply to
I have never been successful in creating a mod to get a random record. Sorry.

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





Quote Reply
Re: Hack, hack, hack. Help! (+ Feature Request) In reply to
Steve: Thank you, your suggestion worked very well!

JPD: I saw an earlier post on the matter (missed it the first time) I'll try it, and should I be succesful in implementing it, I'll post what I found.

Here's a question that I'm kind of wondering about. Wouldn't a random record simply go something like this?:

$recs = ID column to an idList
(for every record get IDKey, set them to a list)
cnt = count number of records in $recs
result = generate rand from 0 to cnt
get ID column of record #results

and use the link <a href="db.cgi?uid=default&function=rand=1>link</a>

Or are there (not-so) subtleties involved due to PERL?
Quote Reply
Re: Hack, hack, hack. Help! (+ Feature Request) In reply to
Yes, I suppose you could go about it that way. (I guess it just seems excessive to me to go through all that. Smile )

What I would do is
-- Open the file
-- Read the lines into an array
-- Close the file
-- Go through each line
-- Put the key value into a second array
-- Get a random number between 0 and the number of items in the second array
-- Get the record that corresponds to the matching key value.

I did just think of an easier way to do it, if you knew that you didn't have any blank lines or comment lines in your database.

-- Open the database
-- Put all the lines in an array
-- Close the database
-- Get a random number between 0 and the number of items in the array of lines
-- Print out the record for that line.

It wouldn't require going through each record to pull out the key value and also would only require opening the database one time.

Further refinement of the above, in case your database did have blank lines or comment lines in it.

-- Open the database
-- Put all the lines in an array
-- Close the database
-- Get a random number between 0 and the number of items in the array of lines
-- If it's not a blank or a comment line
---- Print out the record for that line.
-- If it is a blank or a comment line
---- Get another random number and try again.

(This is how I think. Smile I just thought I'd write out the process this time.)

This will work very nicely for one random record. Getting more than one random record would be more involved.


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