PDA

View Full Version : Affiliate links


rs25.com
12-12-2008, 01:35 AM
Are there any plans to support affiliate links within the system? I could really use this feature.

Clearly I would want a display link as www.site.com and then the affiliate link which was not visible but replaced the URL in the href tag, such as www.site.com?aff=123

Also, what's the liklihood of a site-wide search and replace for URLs, so if someone enters a link to site.com vBulletin re-writes it the the affiliate URL if it exists in vBa Links? That would be really very powerful, and a strong selling point for your product as now it could help monetize sites and provide revenue.

rs25.com
12-13-2008, 04:17 PM
Okay, now this doesn't make any sense. I am looking at the template ADV_LINKS_SHOWLINK and the code that outputs the HTML is as follows:


<td width="80%"><a href="showlink.php?$session[sessionurl]do=goto&amp;l=$link[linkid]&amp;linkurl=$link[linkurl]" <if condition="$show['nofollow']"> rel="nofollow"</if>>$link[linkurl_display]</a></td>

Now CLEARLY the system has a $link[linkurl] and also has a $link[linkurl_display] built in. However, there is no way to enter a different link url versus the display url. Why? How can I change this?

At the very least I would like to refer to a custom field I have created call "affiliate url". How can I reference that so I can have some control over this?

Looking back at searches this is something people have been asking for since 2004, and it seems like it's RIGHT there, so how do we make this work?

Our Sponsors
 

rs25.com
12-13-2008, 04:42 PM
Okay, so I have a custom field2 I've made now, and it works the way I want it to work, how do I reference it in the ADV_LINKS_SHOWLINK template?

This is what I have:

<a href="showlink.php?$session[sessionurl]do=goto&amp;l=$link[linkid]&amp;linkurl=$link[linkurl]" <if condition="$show['nofollow']"> rel="nofollow"</if>><if condition="empty($cfieldvalue[field2])">$link[linkurl_display]<else />$cfield[field2]</if></a>
I have tried:

if condition="empty($cfieldvalue[field2])"
if condition="empty($cfield[field2])"
if condition="$cfield[field2] != ''"
if condition="$cfieldvalue[field2] <> ''"

And several other variations... :(

How do I (a) check for the variable and (b) see if it's got a value?

Brian
12-15-2008, 11:51 AM
The $link[linkurl_display] variable was added to work with the 'Maximum Characters of URL to Display' setting, so that's only used to show the shortened version of the URL.

Custom fields are handled in a loop, so you're not going to be able to display those in custom locations without modifying the code.

Our Sponsors
 

rs25.com
12-15-2008, 11:59 AM
Gotcha.

What about if I refer to it by index, such as $cfield[field2][1] or similar?

Brian
12-15-2008, 12:13 PM
If I'm thinking correctly, you could still use $link[fieldX] within the template, though i would just be the raw data and not show BB code and such parsed.

rs25.com
12-15-2008, 12:47 PM
Okay, that sort of works, but it seems that the system is creating BB Code for the link I am entering in field2, so instead of giving me the raw data, such as:

www.site.com/?aff=123

It is giving me this:

[url =http://www .site.com/?aff=123]www.site.com[/ url]

So then when I try to put it in my HTML, this is what I get:

<a href="showlink.php?do=goto&amp;l=9&amp;linkurl=<a href="http://www.site.com/idevaffiliate/idevaffiliate.php?id=79" target="_self">http://www.site.com/idevaffil...iate.php?id=79</a>" >http://www.site.com/</a>

Is there any way to make it so that it won't parse the URL and just give me the field data?

Here is my modification the template now:

<if condition="$link[field2] == ''">
<a href="showlink.php?$session[sessionurl]do=goto&amp;l=$link[linkid]&amp;linkurl=$link[linkurl]" <if condition="$show['nofollow']"> rel="nofollow"</if>>$link[linkurl_display]</a>
<else />
<a href="showlink.php?$session[sessionurl]do=goto&amp;l=$link[linkid]&amp;linkurl=$link[field2]" <if condition="$show['nofollow']"> rel="nofollow"</if>>$link[linkurl_display]</a>
</if>

This works fine except for parsing the URL which I don't want it to do. Besides, I am not sure how it's parsing that URL, as it should just be the value in the custom field. Perhaps I am referring to the wrong variable?

rs25.com
12-15-2008, 12:51 PM
Now this is weird, when I am NOT logged in (guest mode) the URL is slightly different:

<a href="showlink.php?do=goto&amp;l=9&amp;linkurl=[url ]http://www.forextester.com/idevaffiliate/idevaffiliate.php?id=79[/ url]" >http://www.forextester.com/</a>

This is much closer to what I want, if I can get rid of the [url] tag wrapping the link in the href ... :)

rs25.com
12-16-2008, 07:35 PM
If I were to modify the code, where would I have to tweak this? Is this the core vBulletin URL parsing code (I assume) or vB Links code I can tweak independently?

Brian
12-17-2008, 01:43 PM
Scratch what I said about $link[fieldX] not having the BB code parsed. I was out of town and couldn't really look at the file on Monday, but the code should still be parsed.

Looks like the best way for you to use that field within your code is going to be to add a new plugin to the 'vba_links_showlink_showdetails_complete' hook location with the following code:
$link['field2'] = strip_tags($link['field2']);

That should remove any HTML from the custom field and leave you with the raw text.

rs25.com
12-17-2008, 02:17 PM
Looks like the best way for you to use that field within your code is going to be to add a new plugin to the 'vba_links_showlink_showdetails_complete' hook location with the following code:
$link['field2'] = strip_tags($link['field2']);

That should remove any HTML from the custom field and leave you with the raw text.
That works GREAT ... but only what I am logged in. :D

Guests still see this:

<a href="showlink.php?do=goto&amp;l=9&amp;linkurl=[url ]http://www.forextester.com/idevaffiliate/idevaffiliate.php?id=79[/ url]" >http://www.forextester.com/</a>

Any ideas? :)

rs25.com
12-17-2008, 02:19 PM
Oh, one more thing - while the URL is appearing properly, the showlink.php file is still sending users to the main link, not the field2 link. :(

Brian
12-17-2008, 03:21 PM
Are you sure you're not pulling the page from cache? There shouldn't be any way it would parse things differently for guests.

Any link that points to showlink.php?l=X is going to redirect to that link's URL, regardless of what the 'linkurl' var is set to. That variable is mostly just there so that other software checking for reciprocal links can still recognize it as a link back to their site.

rs25.com
12-17-2008, 03:45 PM
Yeah, I just tried it from a different computer, different browsers (IE, FF) and did a hard refresh - same result.

Oh, I need it to direct to the new affiliate link. Any chance I can tweak that somehow? The goal is to get users to that affiliate link so I can get credit for sales, etc.

rs25.com
12-30-2008, 12:22 PM
Any updates? As a paid product, I would hope we can get a little tech support for this....

Brian
12-30-2008, 02:57 PM
Sorry I missed your previous reply. Though keep in mind that customizations to software do generally fall outside the realm of tech support.
The only other thing I can suggest would be to also use the strip_bbcode() function.
$link['field2'] = strip_tags(strip_bbcode($link['field2']));

rs25.com
12-30-2008, 09:26 PM
That's okay, I thought I'd "poke" you a little to see if I could provoke a response. ;) I'll give that a shot and get back to you with the results. :D

rs25.com
01-06-2009, 05:17 PM
Ok, that didn't seem to help ... next question.

In the file showlink.php, lines 71 - 83, we have this code:

// ##### Go to URL ############################################################
if ($_REQUEST['do'] == 'goto')
{
$vba_links->load_link();
$link =& $vba_links->_link; // set for the redirect phrase

($hook = vBulletinHook::fetch_hook('vba_links_showlink_goto')) ? eval($hook) : false;

$db->query_write("UPDATE LOW_PRIORITY " . TABLE_PREFIX . "adv_links SET views = views+1 WHERE linkid = $linkid");

$vbulletin->url = $vba_links->_link['linkurl'];
eval(print_standard_redirect('adv_links_transferring'));
}


How can I change that so it will look to see if field2 exists, and if so then send users to that URL?

I tried this with no luck...

// ##### Go to URL ############################################################
if ($_REQUEST['do'] == 'goto')
{
$vba_links->load_link();
$link =& $vba_links->_link; // set for the redirect phrase

($hook = vBulletinHook::fetch_hook('vba_links_showlink_goto')) ? eval($hook) : false;

$db->query_write("UPDATE LOW_PRIORITY " . TABLE_PREFIX . "adv_links SET views = views+1 WHERE linkid = $linkid");

if ($link['field2'] <> "")
{
$link['linkurl'] = strip_tags(strip_bbcode($link['field2']));
}

$vbulletin->url = $vba_links->_link['linkurl']; eval(print_standard_redirect('adv_links_transferring'));
}


I also tried like this:

if ($link['field2'] <> "")
{
$link['linkurl'] = $link['field2'];
}

but it still goes to the main link.

Any suggestions? :D

Brian
01-07-2009, 12:02 PM
Custom fields are not loaded by default with the load_link() function since they're not always needed. Use this for the function instead:

$vba_links->load_link(true);

Then you can just use this to check if the field is set:
if ($link['field2'])
{
$vba_links->_link['linkurl'] = $link['field2'];
}

rs25.com
01-07-2009, 12:11 PM
Okay, that does put the URL in the system, but it snips it in the middle, like this:

<a href="showlink.php?do=goto&amp;l=27&amp;linkurl=http://www.CommercialNetworkServices...a_bid=2ea2725a" >http://www.CommercialNetworkServices.com/VPS/Windows/Traders/</a>

I checked the settings in the admin and set the Maximum Characters of URL to Display to 800, but no luck.

Brian
01-07-2009, 02:38 PM
It should return the exact code that was entered for that link since there's nothing being run on those custom fields... Wouldn't hurt to run the strip_bbcode() function on the field though.

if ($link['field2'])
{
$vba_links->_link['linkurl'] = strip_bbcode($link['field2']);
}