Currently the affiliate link is www.mywebsite.com/affiliate/username/page
is there anyway to change my code so the link can be mywebsite.com/page/affiliate/username?
In other words, move the affiliate directory or make it so the affiliate information can be at the end of the url instead of in the middle.
I'm trying to create custom affiliate links and i'm lost as to how, if possible, to insert "/affiliate/username in the middle(after domain and before current page)
Thanks
Comments
Comment #1
bojanz commented"I'm trying to create custom affiliate links and i'm lost as to how, if possible, to insert "/affiliate/username in the middle(after domain and before current page)"
- I'm not sure I understand the problem here, can you elaborate?
As for the moving of the affiliate part to the end of the url, it's possible ( would require heavy changes to uc_affiliate2_init, or the _click() function which is called from there), but I'm not sure what you would gain by doing that.
Comment #2
IWasBornToWin commentedRight now the difference between a regular url and an affiliate link is when the string "/affiliate/username/" is inserted into the link. But the string isn't simply added to the link, it's inserted in the middle, between the domain name and any "/node".
If I were able to have a link with the affiliate info at the end it would enable me to do a function call and grab the current url with something like window.location.href and then add the affiliate info at the end.
Currently if the current url is window.location.href or www.mydomain.com/page1 and I want to have an automated function that creates an affiliate link on the fly using the current logged in user's username, then I have to somehow figure out a way to insert "/affiliate/username in between .com/page1. Maybe there's a way to do it but I'm not an experienced programmer (obviously)
I hope I explained it a little better this time.
I'm trying to enable an affiliate to click a button on any page and get an affiliate link for that page with their affiliate info in it.
Thanks
Comment #3
bojanz commentedLet me help you.
You just need to do a javascript replace, replacing .com/ with .com/affiliate/the_affiliate_id/
Something like this:
var url = window.location.href; // url of the current page
var affiliate_id = ''; // the affiliate id here. You can pull it from the content, or whatever
var affiliate_url = url.replace('.com/', '.com/affiliate/' + affiliate_id + '/'); // the replace
I think this is faster than reimplementing module code ;)
Let me know if you have any more questions.
Comment #4
bojanz commented