It looks like this module supports subdomain links (well it's supposed to), links by path (affiliate/123/whatever), and links by query value (though I only found out by checking the source). Any links it gives out, however, appear to always be by path. I'm submitting a patch that makes it optional what kind of links it generates for use by affiliates.

I ended up creating a central function to handle the creation of all links called _uc_affiliate2_generate_link() that takes the place of l() or url() depending on the options its given. I believe I documented it well enough. It can be made simpler by only ever working like url() would, but that means you need two function calls if you actually want <a> tags. Any input is welcome.

One thing to note is that with subdomains, not all usernames make valid subdomains (for example, spaces are valid in usernames). For now, that case is handled by generating path-style links instead (example.com/affiliate/123) for such users. Let me know if you prefer a different way.

In addition to changing the way links are generated, there are also some small changes to the Affiliate Dashboard page (at user/UID/affiliate). The Affiliate Links section on that page changes its description of how links work depending on which type is the default. I also changed the textarea that shows the text link so it uses the same textarea that forms use because it looks better and it's resizable. In addition, the "Click here for product links" link is in a <p> tag so there isn't so much space between it and the new textarea when there doesn't happen to be any banners.

Also, I felt uncomfortable with the placeholders used in the description of affiliate links, so I changed the ! characters to @ characters. It seems standard practice to sanitize even input from administrators. If you don't like any of those changes, let me know (especially with the uids because I can't see them not being numbers).

Comments

darktygur-1’s picture

Status: Active » Needs review
StatusFileSize
new7.85 KB

Here's the patch.

darktygur-1’s picture

Whoops, sorry about the .diff extension. Looks like I can't change it.

bojanz’s picture

Status: Needs review » Needs work

The subdomain support has been removed, which means that this patch needs to be updated.

However, I'm fine with only using path links for generating links.
You can roll your other changes (sanitation, params) in a new patch.

darktygur-1’s picture

Status: Needs work » Needs review
StatusFileSize
new6.95 KB

Here's a new patch against the code as it was when I grabbed it yesterday. We would like to use query arguments in our links.

Along with removing all references to subdomains, I made some improvements. I created a new _uc_affiliate2_generate_url() function as a replacement for url() when generating affiliate links. _uc_affiliate2_generate_link() always works like the l() function now. The $type argument became an option, because the usual case is to just use the default. Also, the example urls cited in the Affiliate Dashboard page now use the actual site's url rather than example.com.

I was undecided on whether to keep the underscores at the start of the two function names. I'd like them to be useful for anyone (even in other modules) to generate affiliate links. And underscores at the start of function names often seems to mean "private".

darktygur-1’s picture

StatusFileSize
new6.97 KB

Updating the patch so that it actually applies against the latest dev version.

bojanz’s picture

Forgot about this, will review it ASAP.

bojanz’s picture

Status: Needs review » Fixed

Modified the function names to be more sane & committed the patch.

Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

CHI.seo2design.com’s picture

Issue tags: +affiliate link, +sub-domain

How can i use affiliate`s sub-domain as affiliate-uid.domain.com with http://domain.com/affiliate/uid instead?