I have a challenge for all you aspiring module developers out there.
I have a custom PN module we call pnlists (viral listbuilding) that assigns all members an affiliate ID like:
http://domain.com/index.php?module=pnlists&affiliateID=1
Currently, to make it vastly easier for people to actually USE their affiliate ID, I create (manually) subdomains that re-direct to this nasty affiliate ID.
So that members can use http://handle.domain.com instead.
If anyone has an idea on how to automate this procedure (I'm facing an influx of 1000 members a month to one of my sites), I'd greatly appreciate it! :)
Steve
Watch
GitHub Core
Show your support for Zikula! Sign up at Github account and watch the Core project!
GitHub Modules
- mesteele101 responded to »ERR (3): E_USER_ERROR: Smarty error: [in pagesvar:pagesitem2en line XXX]…« 07:01 AM
- mazdev responded to »Pages 2.5.0 and updating - Page not found« 06:41 AM
- ehdwma created topic »Hide "Register new account" and change template to 3 col« 06:27 AM
- mesteele101 responded to »Zikula 1.3.3 - Selecting a category in Pages not working« 01:29 AM
- mdee created topic »How to implement returnpage ?« 01:00 AM
- nestormateo responded to »Fillters in Clip« 24. May
- damon responded to »Can the Updated Version Check be Turned Off (Z 1.3)« 24. May
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
Module hack or new development?
-
- Rank: Developer
- Registered: Jan 14, 2004
- Last visit: Oct 21, 2009
- Posts: 348
I know it isn't what you are looking for, but I would make your pnlists module put a link in the persons 'You Account' page that linked to the correct affiliateID. Then when the user logged in they would just go to their 'Your Account' page and click on the link which would automatically take them to the right page. Then you wouldn't need to do any extra work when new affiliates are created and you don't need any fancy re-write rules, etc that would need to be processed for every user.
Granted it isn't quite as convenient for your end users.
-Chris -
**unknown user**
- Rank: Registered User
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 29
Quote
I would make your pnlists module put a link in the persons 'You Account' page that linked to the correct affiliateID
I have no idea what this would accomplish. What I need is a URL completely external to the site
such as
name.sitename.com
that accomplishes the same thing as the above really nasty looking URL using mod-re-write, so that nobody is left trying to promote the site with that ugly mess. and everyone will be able to even pass their affiliate URL over the PHONE, it will be so simple.
:) -
- Rank: Developer
- Registered: Jan 14, 2004
- Last visit: Oct 21, 2009
- Posts: 348
Ok, this idea intrigued me enough to play with it for a while. The problem is that I don't know for sure exactly what it is you are looking for, but assuming all you want is for http://handle.domain.com to be directed to
http://handle.domain.com/index.php?module=pnlists&affiliateID=1 and NOT http://handle.domain.com/index.php?module=PNphpBB2 or any other URL besides the base file with no query string. And if they enter http://www.domain.com that it goes to your normal start page, etc. Then the following should work.
The easiest way that I could find to do this which would require no URL rewrites, or additional work on your part would be to do the following.
In your pnlists module in the file pnuserapi.php you would need to create a function that returns the ID number that corresponds to a given 'handle'. For an example I would create the function pnlists_userapi_getAffiliateID() and put it in /modules/pnlists/pnuserapi.php. The purpose of this function would be to take a string input 'handle' and figure out what the corresponding affilliateID was. I assume you have some table in your database that maps affiliateID numbers to the handle that you have given the person. pnlists_userapi_getAffiliateID() takes as an argument the 'handle' from handle.domain.com and returns the appropriate ID number.
Then in your main index.php file (core file in the PostNuke directory) I would add the following code:
Code
list($affiliate,$server,$domain) = explode('.',$_SERVER{'HTTP_HOST'});
if ((strtolower($affiliate) != 'www') && empty($_SERVER{'QUERY_STRING'})) {
if (pnModAPILoad('pnlists','user')) {
$_REQUEST{'affiliateID'} = pnModAPIFunc('pnlists','user','getAffiliateID',array('handle'=>$affiliate));
$module = 'pnlists';
$func = 'main';
}
}
I would add it right after this code:
Code
// Get variables
list($module,
$func,
$op,
$name,
$file,
$type) = pnVarCleanFromInput('module',
'func',
'op',
'name',
'file',
'type');
Then if anyone goes to http://pawmarks.yourdomain.com/ the server will bring up the page:
http://pawmarks.yourdomain.com/index.php?module=pnlists&affiliateID=XYZ where XYZ is the affiliateID for pawmarks.
If they go to http://pawmarks.yourdomain.com/index.php?module=PNphpBB2 then it will take them to the forums just like it would normally.
This is assuming your pnlists code uses pnVarCleanFromInput('affiliateID') to get the affiliateID from the system.
This also assumes that your DNS server is set to route *.yourdomain.com to your server.
Hope that helps.
If it doesn't then you will need to describe exactly what it is you want a little better.
-Chris -
- Rank: Developer
- Registered: Jan 14, 2004
- Last visit: Oct 21, 2009
- Posts: 348
One additional change. The code in my previous post will run into a problem if the handle doesn't have a valid affiliateID. This code fixes that problem.
Code
list($affiliate,$server,$domain) = explode('.',$_SERVER{'HTTP_HOST'});
if ((strtolower($affiliate) != 'www') && empty($_SERVER{'QUERY_STRING'})) {
if (pnModAPILoad('pnlists','user')) {
$affiliateID = pnModAPIFunc('pnlists','user','getAffiliateID',array('handle'=>$affiliate));
if ($affiliateID) {
$_REQUEST{'affiliateID'} = $affiliateID;
$module = 'pnlists';
$func = 'main';
}
}
}
Your pnlists_userapi_getAffiliateID() function should return false if there isn't a valid affiliateID for the given handle.
-Chris
- Moderated by:
- Support
