Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

jumping to different urls depending on template

Quote Reply
jumping to different urls depending on template
Hi,

I need some help!

What I want to to is to store multiple URLs for every link (url, afilate_url1, afilate_url2 ...).

Then I want, (based on the selected template) to choose to which of the URLs jump.cgi (or whatever) jumps to.

How can I do this ?

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.

Last edited by:

ManuGermany: Dec 6, 2002, 6:27 AM
Quote Reply
Re: [ManuGermany] jumping to different urls depending on template In reply to
I think it depends whether you want to track the click throughs.

If not, it's easy as you just use the name of the field instead of jump.cgi. If you do, you could copy jump.cgi to jump2.cgi and Jump.pm to Jump2.pm and with some fiddling use this instead. (If you do this, the hits will not be counted by the ExtraStats plugin). I think the best option is to write a simple plugin (it is simple as I've done it!) with a hook for jump_link, make it a pre hook running LAST. Then replace the current jump_link sub using $goto=$IN->param('url') instead of the URL field. Then, whenever you want to use one of the other links you would use <%db_cgi_url%>/jump.cgi?ID=<%ID%>&url=<%afilate_url1%> etc.

Hope I've explained this clearly enough. If not, let me know and I'll try again.

Laura.


Edit: Thinking about this more, you could use <%db_cgi_url%>/jump.cgi?ID=<%ID%>&url=1 or <%db_cgi_url%>/jump.cgi?ID=<%ID%>&url=2 and use something like this in the plugin:

if ($IN->param('url') eq '1'){$goto=$rec->{afilate_url1};}

elsif ($IN->param('url') eq '2'){$goto=$rec->{afilate_url2};}

else {$goto=$rec->{url};}
The UK High Street

Last edited by:

afinlr: Dec 6, 2002, 12:35 PM
Quote Reply
Re: [afinlr] jumping to different urls depending on template In reply to
In Reply To:

Edit: Thinking about this more, you could use <%db_cgi_url%>/jump.cgi?ID=<%ID%>&url=1 or <%db_cgi_url%>/jump.cgi?ID=<%ID%>&url=2 and use something like this in the plugin:

if ($IN->param('url') eq '1'){$goto=$rec->{afilate_url1};}

elsif ($IN->param('url') eq '2'){$goto=$rec->{afilate_url2};}

else {$goto=$rec->{url};}


Hi and thanks for your reply !

Would the code above track the clicks (not url specific but for the ID (link))??

Wouldn't it be more usable to use the table's field name for te url-parameter

e.g: <%db_cgi_url%>/jump.cgi?ID=<%ID%>&url=AfilateURL1 (table: Links -> field: AfilateURL1)

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] jumping to different urls depending on template In reply to
Yes, I was just thinking that you could do it without showing the url to the user but if that doesn't matter to you then you could just use the field in the url.

If you use the plugin with a jump_link hook then it will track clicks for the link and not the url. If you want to track clicks for the url it would be a bit more complicated.

Laura.
The UK High Street
Quote Reply
Re: [afinlr] jumping to different urls depending on template In reply to
ok, both options are good.

you are right that not showing the url to the user is much better.

is there a way to use the jump_link hook for a copy of jump.cgi and jump.pm (jump2.cgi and jump2.pm), so that the original jump-files can stay in use for my "own" site without any modifications? (/jump2.cgi?ID=XX&url=1)

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] jumping to different urls depending on template In reply to
Not sure why you would want to use the copies? You can still use /jump.cgi?ID=<%ID%> and miss off the url field and it will just act as normal - as long as you write a suitable if clause in the plugin. Maybe I'm not understanding what it is you're trying to do.
Quote Reply
Re: [afinlr] jumping to different urls depending on template In reply to
... I was just thinking ;-)

O.K. am I right that I have tho create a Plugin with a PRE Hook running LAST for jump_link and then put the following into the plugin-PM:




sub jump_link {
# -------------------------------------------------------------------
# This subroutine will get called whenever the hook 'jump_linkafili'
# is run. You should call GT::Plugins->action ( STOP ) if you don't
# want the regular code to run, otherwise the code will continue as
# normal.
#
my (@args) = @_;
my ($rec, $goto);

if ($IN->param('url') eq '1'){$goto=$rec->{AfilateURL1};}

elsif ($IN->param('url') eq '2'){$goto=$rec->{AfilateURL1};}

else {$goto=$rec->{URL};}


return @args;
}




Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] jumping to different urls depending on template In reply to
No, unfortunately the goto variable is defined within the sub so you can't just define it and feed the new value in. (If anyone form GT is reading this it would be really helpful if the goto variable could be available like this GT::Plugins->dispatch ($CFG->{admin_root_path} . '/Plugins', 'jump_link', \&_plg_jump, {$goto});)

You need to copy the whole sub _plg_jump from Jump.pm into your sub jump_link and modify it. Something like this (I've taken out bits that I thought were unnecessary but you should check you don't need them - like the file bit)

sub jump_link {
# -------------------------------------------------------------------
# This subroutine will get called whenever the hook 'jump_linkafili'
# is run. You should call GT::Plugins->action ( STOP ) if you don't
# want the regular code to run, otherwise the code will continue as
# normal.
#
my $args = shift;
my $url = $IN->param('url');

my $goto;

if ($url) {
my $db = $DB->table('Links');
my $id = $IN->param('ID');

# Otherwise, if we have a link, let's look it up.
if (defined $id) {
if ($id !~ /^\d+$/) {
require Links::SiteHTML;
print $IN->header();
print Links::SiteHTML::display('error', { error => Links::language ('JUMP_INVALIDID', $id) });
return;
}

my $rec = $db->get ($id);

if (! $rec or ($rec->{isValidated} eq 'No')) {
require Links::SiteHTML;
print $IN->header();
print Links::SiteHTML::display('error', { error => Links::language ('JUMP_INVALIDID', $id) });
return;
}

if ($IN->param('url') == 1){$goto=$rec->{AfilateURL1};}
elsif ($IN->param('url') == 2){$goto=$rec->{AfilateURL2};}
else {$goto=$rec->{URL};}

# Jump to a URL, bump the hit counter.
my $ip = $ENV{REMOTE_HOST} || $ENV{REMOTE_ADDR} || 'None';
my $click_db = $DB->table ('ClickTrack');
my $rows = $click_db->count ( { LinkID => $id, IP => $ip, ClickType => 'Hits' } );
if (! $rows) {
$db->update ( { Hits => \"Hits + 1" }, { ID => $id }, { GT_SQL_SKIP_INDEX => 1 } );
$click_db->insert ( { LinkID => $id, IP => $ip, ClickType => 'Hits', Created => \"NOW()"} );
}
}
# Oops, no link.
else {
require Links::SiteHTML;
print $IN->header();
print Links::SiteHTML::display('error', { error => Links::language ('JUMP_INVALIDID', $id) });
return;
}
if (! defined $goto) {
require Links::SiteHTML;
print $IN->header();
print Links::SiteHTML::display('error', { error => Links::language('JUMP_INVALIDID', $id) });
return;
}

($goto =~ m,^\w+://,) or ($goto = "http://$goto");
if ($goto) {
print $IN->redirect ($goto);
}
else {
require Links::SiteHTML;
print $IN->header();
print Links::SiteHTML::display('error', { error => Links::language ('JUMP_INVALIDID', $id) });
return;
}
GT::Plugins->action ( STOP );

}

return $args;
}
The UK High Street

Last edited by:

afinlr: Dec 6, 2002, 2:52 PM
Quote Reply
Re: [afinlr] jumping to different urls depending on template In reply to
You shouldn't be using eq '1' and eq '2' - it should be == 1 and == 2
Quote Reply
Re: [afinlr] jumping to different urls depending on template In reply to
heySmile!

Thank you very much for your help!

I am goinig to test this out!

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] jumping to different urls depending on template In reply to
Just spotted that I hadn't declared the goto variable so I've just done a quick edit on my previous post (and added Paul's suggestion - thanks again for clearing up my mistakes Paul Tongue)

Hope it works!

Laura.
The UK High Street
Quote Reply
Re: [afinlr] jumping to different urls depending on template In reply to
ok,

I'v just tested the plugin with all the changes but somehow it doesn't work. It always jumps to the standard URL.

Crazy

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] jumping to different urls depending on template In reply to
CrazyCrazyi dont know why, but suddenly it works!!



Thanks a lot to both of you!

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] jumping to different urls depending on template In reply to
Edit: Missed the last post!

Glad its working.

Last edited by:

afinlr: Dec 6, 2002, 3:43 PM
Quote Reply
Re: [afinlr] jumping to different urls depending on template In reply to
Again! Thanks a lot!

Now there is one point off of my to-do-list.

Now I'm going to programm a Template-Creator (so users can design their own templates by using my content [using <%include%> or IFRAME]) and a product-database which imports the data from uploaded CSV-Files into a SQL-Database.

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] jumping to different urls depending on template In reply to
Ooh, I would be very interested in what you do with the products database if you're willing to share it Angelic

I have created a database for products but I've never got round to using it because I wasn't sure how to go about updating the information. Any tips you can pass on would be very much appreciated!

Laura.
The UK High Street
Quote Reply
Re: [afinlr] jumping to different urls depending on template In reply to
@product-database:

I'm still thinking about this.

The fact is that I want to import the complete product data of online-shops which have afilitate-programs.

There should be two ways to import the data:

1.) They provide the URL to me, where the actual data can be found so I can spider them

2.) The Shop-Owners can upload their CSV-Files, define in which column are product-ID, product_title, price, image-src,etc.) and then add all to the database (entries will expire after round about 14 days).

I just have posted to the DBMan SQL-Forum to see if this product will fit.



By the way: The template creator will be also very nice if you need hi click-rates to the linksin the database (as an argument for premium-links)

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] jumping to different urls depending on template In reply to
That is exactly what I want to do - get complete product databases. Getting them in there the first time is one problem but the one I couldn't see how to tackle at all was how to update the entries every so often - and delete ones that were no longer valid. I suppose you could just delete all the relevant entries before respidering or reimporting?

I am also interested in the template creator but I was just really excited to see that someone else was thinking about product databases as its been something that I've wanted to do for ages.

Laura.
The UK High Street
Quote Reply
Re: [afinlr] jumping to different urls depending on template In reply to
Yes, me too ("wanted to do for ages") as I've a shopping-directory!!!

I think to delete expired data should work with a little cgi and cron.

the point is you have to store the date, when the entries(products) are submitted to the database and then delete all expired data by running the cgi via cron at night.

the biggest problem I see is indeed to always get the actual data. Therefor I have several thing on my mind.

but I think the biggest problem first is, to manage to import CSV-data, uploaded by users and manage that the user can define the columns so the data will fit to the database.... and that my perl-knowledge is anything-- but not good!

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] jumping to different urls depending on template In reply to
CoolCoolhey is this a forum or a chat ??!

CoolCool

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] jumping to different urls depending on template In reply to
OK, I'll think about this and get back to you if I come up with anything.
Quote Reply
Re: [ManuGermany] jumping to different urls depending on template In reply to
hi I've tried to use this, but as stated by ManuGermany it only jumps to the normal URL value and not the other fields. I'm using the code that afinir posted. Any help?
Quote Reply
Re: [kzap] jumping to different urls depending on template In reply to
Well Manu said that it did work - so I'm assuming that you must be missing something Unsure.

If you are using mod_perl you will need to restart it. Other than that I'm not sure what to suggest.
Quote Reply
Re: [afinlr] jumping to different urls depending on template In reply to
umm how come?

how do i find out if im using mod_perl?