Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Modify Template question

Quote Reply
Modify Template question
What I would like to do is have the person enter a URL, click on it, and if it's in the database, return the form all filled out for changes.

If it's not filled out, I'd like it to load the 'add' form with the url in place.

I looked at the code for modify.cgi, but I think I'm missing something.
Quote Reply
Re: Modify Template question In reply to
You'd want to do something like:

Quote:
my $url = $in->param('URL');

if ($url) {
my ($db, $recs, $rec);
$db = new Links: BSQL "$LINKS{admin_root_path}/defs/Links.def";
$recs = $db->query ( { URL => $url, ww => 1 });
if ($db->hits) {
$rec = $recs->[0];
$rec = $db->array_to_hash ($rec);
&site_html_modify_form ( $rec );
}
else {
&site_html_add_form ( { URL => $rec->{'URL'} });
}
}

You will probably need to add another screen though, one for the first modify page, one for the modify form.

Hope that helps,

Alex
Quote Reply
Re: Modify Template question In reply to
I've been playing with this, off and on, but now I'm really trying to make this work.

I can't seem to get the record to pass to the found records.

Actually, I'm not sure it's really finding the record to pass.

What I did, was set it up so that the modify form has two 'forms' on it. The top one is search for URL and is called "GET_URL".

If that's not empty, or equal to "http://" then it tries to find the URL in the database. If it does, it reprints the modify form with the fields filled in, and if it doesn't, it passes it to the add form with the URL filled. in.

But it's not working.

I've gone through all the code frags that should work -- search.cgi and the admin modify routines, but can't figure out what isn't going on. Taking your code:

The idea is:

Connect to the database:

$db = new Links:: DBSQL "$LINKS{admin_root_path}/defs/Links.def";

Look for the URL and assign it to $recs (forcing an array??)

$recs = $db->query ( { URL => $url, ww => 1 });


Then, if any hits were found:

if ($db->hits) {

Code:

I gather this is attempting to take the first record found.

$rec = $recs->[0];

Then, take that record and convert it to hash format.

$rec = $db->array_to_hash ($rec);

then take that hash, and passit to the modify template.

&site_html_modify_form ( $rec );
}
else {

if the URL wasn't found, pass it to ADD

&site_html_add_form ( { URL => $rec->{'URL'} });
}


I just can't get it to work. I've tried changing the variable types, and such, but there seems to be one step missing, and I can't find it.

I'm lead to believe this since when I try to pass it, the blank template is printed, but it has an "error Unknown Tag Category" .



[This message has been edited by pugdog (edited September 16, 1999).]
Quote Reply
Re: Modify Template question In reply to
Still can't seem to get it to pass properly....

How about adding the 'fill in' feature to the next release too -- it would make the editors lives much easier.