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

do=html_add_form&...

Quote Reply
do=html_add_form&...
I am trying to port my bookmarklets for Links administrators to Links SQL, but am having problems with do something like this:
.../admin.cgi?db=Links&do=html_add_form&Description=Test

In Links 2, "Test" is inserted into the Description textbox at the add_form_error generated page. But not so in Links SQL.

Is there some way of getting it right here?

John

Quote Reply
Re: do=html_add_form&... In reply to
You've really lost me on that one. But are you sure you have the HTML tags set right? I know I had to make some changes to some forms (not sure if it was Links) to get the < TEXTAREA > stuff </ TEXTAREA > tags working right.

The other problem, is where you are using it, are you passing a copy of the $in variables to the template routines?

You might be trying to do something ("add" functionality) to a routine that wasn't fully set up for it.

One of the changes I'm really hoping for in the next release is a standardized interface for all the routines.

http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: do=html_add_form&... In reply to
pugdog,

Sorry for not having explained my issue better, but I am really not sure what the issue is [whine]

As you might know, a bookmarklet is a piece of javascript. This Lins2 bookmarklet for site owners I developed (see the resource center or the Links2 customization forum) works off the the errror message from the Add Link function, in the way that (when clicking the bookmarklet) the javascript grabs something (like URL, Title,...) from a webpage you're visitng, and put that after a & in a URL string that points to ./admin.cgi?db=links&add_form=1:

javascript:Q='';if(top.frames.length==0)Q=document.selection.createRange().text;void(btw=window.open('http://www.gotzespace.dk/links/admin/admin.cgi?db=links&add_form=1&URL='+escape(location.href)+'&Title='+escape(document.title)+'&Description='+escape(Q),'AddToLinks','menubar=1,location=1,resizable=1,scrollbars=1,status=1,toolbar=1'));btw.focus();

In Links2, this works with doing any code changes, since the admin.cgi seems to work differently than the Links SQL one, in that it allows stuff in the URL string itself (http://.../admin.cgi?db=links&add_form=1&stuff_here_that_admin.cgi_interprets.

Obviosly, the add form does work differently, since when bringing up the error message, that is done "internally" (and not seen in the URL). I see it has something to do with the $in variables, but have no idea how to get those into the actual URL.

Hence the message.

John

Quote Reply
Re: do=html_add_form&... In reply to
I'ts as I said, you are asking the function to do something it's not set up to do.

If you follow the path of the function call, at the top of admin.cgi the $in and $db variables are passed to the $sub, which is determined by the calling URL.

that sends (in this case) to html_add_form, in Admin_HTML.pm

In that sub, you see:

Code:
sub html_add_form {
# --------------------------------------------------------
# The add form page where the user fills out all the details
# on the new record he would like to add. You should use
# &html_record_form to print out the form as it makes
# updating much easier. Feel free to edit &get_defaults
# to change the default values.

my ($in, $db) = @_;
my $footer = &html_footer ($in, $db);
my $form = $db->build_html_record_form ($db->get_defaults, { hide_key => 1, show_attach => 1, base_url => "$SCRIPT_URL?do=show_attach&db=$DATABASE&ID=", CategoryID => \&build_category_row });
What this shows, is that the $in (pointer to a cgi object _I_THINK_) is passed to the &html_footer routine, but it is not converted to a local hash -- the routine is _NOT_ expecting any passed parameters.

You'd want to pass:

Tag_Name => $in->param(Tag_Name)

in the call to "build_html_record_form" the way the CategoryID is passed, and assigned the category or list.

Alternatively, you could, I would imagine, convert the $in to a local variable, using "cgi_to_hash" and then pass %$in to the routine.

I'm not sure which, if either,would work right, but that is why you are not getting the values. You'd also probably have to re-do the called routine to know to act on the passed parameters, since the only parameters it's probably expecting is CategoryID (unless it's the same routine used for all the calls, in which case it should automatically process the passed hash values).

but, there-be your problem.




http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: do=html_add_form&... In reply to
Thanks for the explanation, pugdog. I understand the issue at hand. I think I at first wait and see what the new version brings - who knows, perhaps Alex has something up his sleeve.
John

Quote Reply
Re: do=html_add_form&... In reply to
What I am hoping, is that all the routines were rewritten with the same interface, and each routine has the same "expected" behaviour. If you pass a parameter in, you expect it to be passed down the chain, and not have one subroutine or function filter it out.

Hopefully, that is one of the changes :)

http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/