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

Recommend It Mod, will it work with Links SQL ?

(Page 1 of 2)
> >
Quote Reply
Recommend It Mod, will it work with Links SQL ?
hi,
sine this mod didnt require any changes in any scripts in Links 2.0 , i thought that it should work with Links SQL .

has anyone tried this ?
Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
Do you mean Bobsie's mod?

The one based on the BNB script?

If so, it would need to be modified a bit, since it includes db_utils.pl and makes a call to

%rec = &get_record($fields{'ID'}); ## links Mod

to get the record information to pass to the Recommend-It script.

Shouldn't be too hard, but I don't think LinkSQL returns the values the same way, so you'd have to convert it into a hash before moving on.

This should be the only change -- you need to "get" the record, and put it into the %rec hash.

Everything else would appear to work the same, since all the templates use the %rec hash for values, not anything inside links. It's just getting the record _into_ %rec

I'm too tired to think of it now, but if no one else does, maybe by monday -- I just realized that this was giving erroneous results on my site (still beta), so I need to fix it.

Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
You need to do the install as if you were doing Templates, but instead of:


require "/path/to/links.cfg";
require "$db_script_path/links.def";
require "$db_script_path/db_utils.pl";

put:

use lib '/path/to/links/admin';
use Links: Wink

Cheers,

Alex
Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
Beat me to it Smile

That's just about what I figured out would work... but your hash conversion is cleaner.
Now I have to actually go make sure it works Smile

But I think you meant 'ID' not 'id' in the line:


my $rec = $db->get_record ($fields{'id'}, 'HASH');


BTW: remember to change the links in the HTML you return to the people inside the file to reflect the new paths to links if you moved it.


[This message has been edited by pugdog (edited September 07, 1999).]
Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
I knew there was something else ...

This script is _NOT_ mod_perl compatible.

To find all the variables you need to declare with "my" - add "use strict;" to the top of the file, then check your error log for compile time errors.

To remind me of this, I've kept this script in my cgi-bin directory, not the links subdirectory.




Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
Hi, I've been trying to get this mod to work, but this is the error I am getting.

syntax error at /home/chua/directory/cgi-bin/recommend.cgi line 4, near "use Links:"
Execution of /home/chua/directory/cgi-bin/recommend.cgi aborted due to compilation errors.

[Mon Mar 13 23:38:13 2000] [error] [client 63.194.210.53] Premature end of script headers: /home/chua/directory/cgi-bin/recommend.cgi
Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
Looking at the error, I'd like to hope it is as easy as it looks but there may be more to it...

use Links;

should have the semi-colon at the end not the colon.
Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
Has anyone gotten this mod to work with linkssql? I've tried it, but it won't work. If you've gotten it to work, could you post the script either in this forum or in the resource center?

Thanks a lot.
Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
I've hacked the BNB script to work with Links SQL, but it's site specific to my site.

The code says it's freely alterable and distributable, and I may have actually posted it before.

I could take another look at it and see if it's ready for release.

The trick is you want to pass it the "ID" from the link, and then have the script look up the link, so it has all the data. Again, I hacked search.cgi to make this one work.

Let me know if that's the one. I didn't use Bobsie's mod.

Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
Pugdog:

I'd be interested in this, if you have it working. I've tried the other one posted here and can't get it to work either.

Regards,



------------------
Clint
----------------------------------
www.AffiliatesDirectory.com
Proud Supporter of Links SQL
----------------------------------




Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
Sure, could you please post it? Is your mod using the BNB script? I would feel more comfortable not making a mod on a critical script (namely search.cgi) Is that how yours works?
Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
The mod is to the BNB script, using search.cgi as a guide. Remember, build on the parts already built and working.

I didn't template-ize it, but I guess I could have.
Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
Could you please post the script?
Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
Actually, I'm looking at the script now, and it's embarrassing. It shows I really knew nothing about Links SQL or anything when I tried to mod it -- I'm actually surprised I got it to work.

I think I can rewrite it more easily than I can fix it, and it will use templates, similar to the search/add feature.

My script also used a field to count how many times a link was recommended, so actually I'm counting page hits, site hits and how many time recommended for each link.

I think I can cut out all the hard coded stuff, and make this use all links routines so it will be easy to maintain.

I can set it to run with or without the additional field to track recommendations.

I should have it finished in a day or two. This is so embarrasing I _HAVE_ to fix it Smile

If you want to see it in action, check it out at:


http://www.postcards.com/cgi-bin/postcast_SQL.cgi?ID=427


All it takes is the ID=nnn parameter, and it takes all the information out of the database.

Obviously there is room for improvement, but since I can make it template based, and use standard Links SQL elements, you'll be able to make the template do what you want. _ALL_ the 'link' tags should be available, and I guess I could do a category look up, but maybe not Smile Something has to be left to the viewer <G>.

Now that I know what I'm doing (sort of) it's really not hard to make this sort of thing. Actually -- it's just a variation of the report-bad-links mods that have been posted.

Same shell of the program, different templates. It takes in the ID as the only parameter, and outputs a template-formatted page to allow you enter the email and names plus a message. Hit submit, and it sends that plus the embedded link ID to the script, that outputs it to a mail message.
Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
Mondays are always bad... I should have this out tomorrow.

Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
Great thanks.
Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
I got lost upgrading one of my main programs with a bug fix release.

I have the recommend it working, but I need to try to put it through the Links mailer, rather than the built in one, because the built in one is not mod_perl compatible.

I'll probably need a few people to feedback and test it, since my mail system is more or less customized to our purposes and is set up to take all our script output.

The program shouldn't do any damage! But if you are _not_ on a virtual host, and you can look at your running processes (with the 'ps' command) that would help! (Making sure the mail process runs and terminates.)

Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
Yeah I'd be willing to test it. Could you send it to me?
Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
Hi,

I had to take a break, and read up on some passing parameters. I was starting to go in circles. I should have it out shortly. I'll point to a download URL and you will be at your own risk! Smile

Every so often I get confused with hashes, arrays, references, hash2cgi, cgi2hash, etc. I have to take a break and sort it back out. (Sort of like a neural overload).

Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
Ok,

I got it working, and it's template based for both the input form, and the email form.

It should be Links SQL compliant through any upgrades, since it makes no direct calls, so unless the module structures change it should be ok.

Now, it's _NOT_ pretty!

I have to clean it up just a bit before I can release it, because some things are hard coded to my setup.

I need to make it flexible enough to not force you to add a new field to your links database to track referrals, and little things like that.

I have a _lot_ of debug code and comments in it, and I don't know whether to strip them out, or leave them in. If you are trying to update the script, they may help (or they may confuse you). They do mark break points, and decision points, if nothing else.

They should _not_ slow the program much. It's only 15k total so you won't save any time on reads, and comments are ignored by the parser so it won't really save you any time there.... It runs under strict without any apparant errors...

But, knocking out all the comments would probably cut the program in half. I use LOTS of comments so I remember what I was doing.

There are two templates -- the html input form, and the email output form. I did not put a confirmation form on it, and I probably should, since it is a little disconcerting to just get taken back to your links page. That should only take a few minutes to add, since it's a straight forward template call.

Should be out tonight....

Show of hands on whether to leave the comments in or out.



Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
I would say no harm in leaving the commnets in. They're easy enough to remove if individuals want to streamline later, and as you said, they may help people to understand your work.

I'm interested to try this mod out, I just need to decide if it's something I have a use for... Wink

Dan
Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
If nothing else, if you follow the comments, and the logic (if you call it that) it will illustrate a whole bunch of links and perl ideas from passing hashes/references to anonymous hashes and subroutines. All sorts of perl "tricks" done in a STRAIGHT FORWARD way.

A really good programmer could take the tricks and do other stuff with them, but I go by the maxim that a "Shortcut is something that saves your time, and wastes everyone elses."

One thing I _do_ know needs done, is the call to &main is a real kludge. It should be broken up into a call to &main then a call to one or 2 other processes, since too much is being done in the "main" that really should only be a create the cgi-object, get the ID record, and then branch by "if posted" or "if not posted" Any one who wants to clean that up, it's sort of obvious.

If you are overly concerned about performance, you need to use optimization tags (to strip the comments and slower code out) or parallel development.

The reason is that when "speed" is a selling feature, you want to design for it, but you need to have code that can be maintained. Often the "tricks" are so obscure they are missed, or may not work in the next release of the compiler. At the very least they slow down the interpretation of the code by those who follow.

I just don't think this script is one where speed counts first of all -- it's by nature a pig of a script. The sendmail or smpt interface is probably the slowest part of this whole thing (maybe the template processing) and any code bloat should be trivial -- or less than trivial -- in comparason.

I'm open to any comments on this, and when people see the code, the terms of the license are to SHARE ANY MODS OR CHANGES or you are in violation of it (sort of a very short GPL license <G> ).

This code is _much_ better than the version I made during the first month, but it's a learning/example code and is definitely NOT pretty. But, there should only be one or two edits in the code file that are needed, and everything else should be done in the templates, which is a good thing --- right? <G> (I might even be able to get that reduced to nothing by the time I release it, since I think the only variables that need to be set are available in Links.pm.) That would make this really plug-n-play and you'd only have to fiddle with your templates.

Oh -- and the one change to count referrals if you want it. There's no way to make that plug-n-play since it needs a database field to be created.








[This message has been edited by pugdog (edited April 12, 2000).]
Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
Ok,

It's out. You can get it from the FAQ at :

www.postcards.com/FAQ/LinkSQL/Detailed/183.html

If you want to see it running at my site, remember, it's not linked into the site, so you need to pass an explict (random) ID number, such as 454.


postcards.com/cgi-bin/DigitalPostcards/recommend_it.cgi?ID=454

I should have it working on my main site later today, but I do that sort of stuff only at night!



------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/



[This message has been edited by pugdog (edited April 12, 2000).]
Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
yep... the category is _not_ stored with the link.

To use that, you'd have to take the CategoryID from the link field, and do a lookup in the Category table, then add the value to passed hash.

I'll see about adding that, since so many people ask about how to use the category, a simple lookup routine might help a bunch. But, by only storing the ID of the category in the link, you can rename, move and do other things to the category name without affecting the links that are in it.

Let me know if anything doesn't work, and if anything needs to clear up. This was _very_ tightly bound to my site, and I generalized it, but every site is a bit different.

Quote Reply
Re: Recommend It Mod, will it work with Links SQL ? In reply to
pugdog, do you know why there is a 1 at the bottom of the recommend page?
> >