|
Advanced Data Generation - Additional Parameters
There are more parameters that you can use to dictate how the data stream appears and
you also have the option to use CRON to retrieve the data for efficiency. Each of the
following are explained in more detail in the relevant sections on this page.
- Truncating Headlines And Descriptions
- Displaying The Creation Date For Items
- Overriding Your Default Affiliate Link
- Filtering Data Types (Promotions, News etc)
- Filtering Items By Keyword
- Randomising The Data Stream Item Display
- Merging Data From Several Properties
- Ensuring The Property Name Appears
- Define Your Own Parameters
- Getting Creative With Images
- Controlling Div ID's for each Item
- Outputting Data Streams As RSS
- Using CRON To Retrieve Data Streams
A quick reference guide to all parameters can be viewed here.
You can change the look and feel of every data stream too...see the
Changing colours & fonts section for more information.
Truncating Headlines And Descriptions
To set the maximum length of headlines and/or descriptions on each item in a data
stream, add either or both the parameters "maxheadlinelen"
and "maxdesclen" as highlighted below. These should be numeric values, specified
as the maximum number of characters to use. The minimum values accepted are "15" for either
parameter. These are optional parameters, and if omitted, the headlines and descriptions
(if used) will appear in full.
An example with truncated headlines and descriptions:
<?php
$params[streamID] = "110000003";
$params[maxitems] = "10";
$params[template] = "headlines_and_descriptions.inc";
$params[maxheadlinelen] = "20";
$params[maxdesclen] = "100";
displayItems($params);
?>
[top]
Displaying The Creation Date For Items
You can also show the time an item was created by adding a {time} indicator
to your template. If you want to display the creation
date, time or a combination of both for each item, set the
$params[timeformat] parameter as shown below. This can take any format where
(lower case) y = year, m= month, d = day, h = hour, i = minutes and s = seconds. You can use
any combination and any format/seperators.
For example:
<?php
$params[streamID] = "110000003";
$params[maxitems] = "10";
$params[template] = "headlines_and_descriptions.inc";
$params[timeformat] = "d/m/y h:i:s";
displayItems($params);
?>
The above example would append a date to each item in the format
"Day/Month/Year Hour:Minute:Seconds" indicating when the item was released.
Note: For the time to display, you must also ensure that {time}
is somewhere in your template layout.
[top]
Overriding Your Default Affiliate Link
There may be the odd occasion where you want to use a specific campaign code on one of
the affCAFF data streams, but your default affiliate link is set up for your whole site. Or
you may just want to redirect the users to another page on your own site that explains
something.
You can achieve this by using the optional "overridelink" parameter. Simply put in
any URL you wish and all items in that stream, on the page where you use this optional
parameter only, will use the new link. Bear in mind this will override the link for all items,
so is best used when displaying just 1 or 2 items from a single property:
For example:
<?php
$params[streamID] = "110000003";
$params[maxitems] = "10";
$params[template] = "headlines_and_descriptions.inc";
$params[overridelink] = "http://www.take-me-somewhere-else.com";
displayItems($params);
?>
Note: You must ensure your link begins with http.
There is also a parameter "$params[appenditemID]" (set to
"Y" or "N") which compliments the "overridelink" parameter and when set to "Y", will
add the Item ID to the end of the Override URL in the format "acItemID=nnnnnn". This
could be useful if you want to send users to a different page on your own website for
the full articles (NB: every item in the affCAFF system has a unique ID).
For example:
<?php
$params[streamID] = "110000003";
$params[maxitems] = "10";
$params[template] = "headlines_and_descriptions.inc";
$params[overridelink] = "/mydirectory/mypage.php";
$params[appenditemID] = "Y";
displayItems($params);
?>
... would send your visitors to your own script called "/mydirectory/mypage.php?acItemID=123456"
(or whatever ID each item has) where you can manipulate the ID as you wish.
[top]
Filtering Data Types
Each item sent over in a data stream will usually fall into one (or more) of three categories:
- Signup Offers
- Promotions
- General News
You can optionally choose to show items from
just one or two of those categories by setting a relevant parameter. If you are going to
display items from all three categories you do not need to include these at all. The three
extra parameters you can choose to use:
- $params[showsignupoffersonly] = "y";
- $params[showpromotionsonly] = "y";
- $params[shownewsonly] = "y";
Any combination of the three can be used, and the setting should always be "y". For example,
if you wanted to show all promotions and signup offers, but not news items, you can
add the parameters as shown below (highlighted in blue).
Example: show upto 10 signup offers or promotions from 1 property:
<?php
$params[streamID] = "110000003";
$params[maxitems] = "10";
$params[template] = "headlines_and_descriptions.inc";
$params[showsignupoffersonly] = "y";
$params[showpromotionsonly] = "y";
displayItems($params);
?>
This can be particularly useful when merging data streams from multiple
properties, for example to just show signup offers from each property. Used on just one
property (as in the example above), you could set the "maxitems" parameter to "1", add
the $params[showsignupoffersonly] = "y"; setting, and your code will always just
show the latest signup offer from that property wherever you place the code on your page.
[top]
Filtering Items By Keyword
There is a simple keyword option that you can optionally use to filter data streams
and show only items containing certain keywords in either the headline or the description.
The "$params[filterwordstitle]" and "$params[filterwordsdesc]" parameters
can be used seperately, together or not at all, but they combine results, so if you use
both, only items that match both filters will show.
Each can contain multiple keywords or phrases, seperated by commas. For example, let's say
you were merging 3 properties into one data stream, but only wanted to
show the items with the word "Poker" or "PKR" (regardless of CaSe) in the headline. Note
that the comma acts as an "OR" - so your headline would only need to contain one of the words to
show up:
<?php
$params[streamID] = "110000003";
$params[maxitems] = "10";
$params[template] = "headlines_and_descriptions.inc";
$mergeStreams[MeacLLC] = "111000004";
$mergeStreams[AcmeLLC] = "111000007";
$params[filterwordstitle] = "poker, pkr";
displayItems($params, $mergeStreams);
?>
You could also add the "$params[propertyintitle]" parameter and set it to "y" if
you wanted to check in the name of the property for "poker" or "pkr" too. How you write "poker"
and "pkr" doesn't matter - use lower case, upper case or a combination - it matches against
all options.
If you wanted to do the above matching on the full text description rather than the headline,
simply replace the "$params[filterwordstitle]" with "$params[filterwordstitle]".
[top]
Randomising The Data Stream Item Display
The parameter "$params[random]" can be used (and set to "y") to randomise
the order of items in a data stream. Every time the page is loaded, the items in the
data stream will appear in a totally random order. This can also be applied when you
merge data streams.
<?php
$params[streamID] = "110000003";
$params[maxitems] = "10";
$params[template] = "headlines_and_descriptions.inc";
$mergeStreams[MeacLLC] = "111000004";
$mergeStreams[AcmeLLC] = "111000007";
$params[random] = "y";
displayItems($params, $mergeStreams);
?>
The affCAFF Homepage uses this method in the "Latest Items" panel.
[top]
Merging Data From Several Properties
If you would like to merge data streams from multiple properties, you can do this
by adding some new parameters prior to the "displayItems()" call.
For each new property whose data you want to add, grab the relevant ID from the
"Data Generator" tool in affCAFF Manager, and add a new parameter for each called
"$mergeStreams[anyname]" (case sensitive and note that "anyname" you set
must not begin with a numeric character or it will fail!). See the example below to
see how 2 more properties have been merged into the original data stream for Property ID
110000003 (remember that each property ID is generated automatically for you in the
data generator so you don't have to know them).
First, an example of standard data stream code for one property...
<?php
$params[streamID] = "110000003"; // 32Red Casino
$params[maxitems] = "10";
$params[template] = "headlines_and_descriptions.inc";
displayItems($params);
?>
...and here is the code with data for two extra Merged properties...
<?php
$params[streamID] = "110000003"; // 32Red Casino
$params[maxitems] = "10";
$params[template] = "headlines_and_descriptions.inc";
$mergeStreams[bet365] = "110000021";
$mergeStreams[intertops] = "110000016";
displayItems($params,$mergeStreams);
?>
...finally, merging 2 extra properties, but showing only promotions...
<?php
$params[streamID] = "110000003"; // 32Red Casino
$params[maxitems] = "10";
$params[template] = "headlines_and_descriptions.inc";
$params[showpromotionsonly] = "y";
$mergeStreams[bet365] = "110000021";
$mergeStreams[intertops] = "110000016";
displayItems($params,$mergeStreams);
?>
You can replace anyname with any text of your choosing to help you remember
which stream is being merged. Also note, that aside from the new "MergeStreams[anyname]"
calls, you have to pass them through to the "displayItems()" function.
There is no limit to the number of data streams you can merge, but the
"$params[maxitems]" setting above may need to be increased accordingly.
[top]
Ensuring The Property Name Appears
There are two ways you can make the property name appear in headlines and descriptions
for each item. The simplest way is to add {property} somewhere in your
template. This will get replaced in each item with the name of the property automatically.
However, if you are adding this to the headline, you may find it is duplicated
if the content provider has already used the name of the property in one or more headlines.
So, if you prefer, you can add the optional parameter "propertyintitle" that will
check whether the property name is already included in the headline, and if not, add it to
the beginning of the headline with a colon following (ie: "32Red: 100% Signup Bonus To £100").
To use this parameter, set it to "Y", or simply leave it out if not required.
For example:
<?php
$params[streamID] = "110000003";
$params[maxitems] = "10";
$params[template] = "headlines_and_descriptions.inc";
$params[propertyintitle] = "Y";
displayItems($params);
?>
[top]
Define Your Own Parameters
You can define "user" parameters for any data stream which pass in information and
is replaced in the resulting data stream. For example, if you wanted to define the headline
font as "arial", you might pass through the following parameter:
$params[u_headlinefont] = "arial";
Note the "u" in "u_headlinefont" - this marks it as a "user" defined parameter. You can have
as many as you wish and call them what you like, as long as they start with "u". To show
the value in a template, add {u_headlinefont} somewhere in your template.
Here is an example passing through 3 user-defined parameters to configure the display:
<?php
$params[streamID] = "110000003";
$params[maxitems] = "10";
$params[template] = "your_template.inc";
$params[u_desccolor] = "#000099";
$params[u_descfontsize] = "-2";
$params[u_author] = "mysite.com";
displayItems($params);
?>
...and here is how "your_template.inc" might look to read them in...
<div class="acItem">
<a href="{link}" class="{class}" target="{target}">{title}</a>
<font color="{u_desccolor}" size="{u_descfontsize}">{description}</font>
<br>Copyright {u_author}
</div>
More on parameters and creating templates...»
[top]
Getting Creative With Images
You can use the optional preset {propertyID} placeholder in your templates,
along with a couple of user-defined parameters (see above) to add an image to each
item in the stream. This would probably work best if you have streams with just one
maxitem displaying, but doesn't currently work with
merged data streams.
All we really need to do is to name your image or screenshot
with the property ID (provided in the Data Generator) and add width and height parameters to
our call thus:
<?php
$params[streamID] = "110000021";
$params[maxitems] = "1";
$params[template] = "your_template.inc";
$params[u_imagewidth] = "200";
$params[u_imageheight] = "150";
displayItems($params);
?>
...and then reference the image in the template...
<div class="acItem">
<a href="{link}" class="{class}" target="{target}">{title}</a>
<img src="/images/{propertyID}.jpg" width="{u_imagewidth}" height="{u_imageheight}">
<br>{description}
</div>
Don't forget to upload your images and name them by the Property ID. In the above example, they would
be placed in your "/images" directory and called similar to "110000021.jpg" where
"110000021" is the Property ID for the data stream.
[top]
Controlling Div ID's For Each Item (Developers)
If you are creating advanced templates using javascript, you may find the optional
parameter "dividprefix" useful for referencing each element in a data stream. Every
item in a data stream is split into two parts, with a DIV element wrapping them together. You
can define your template to give each an "ID" thus:
<div id="{itemDivID}" class="acItem">
<a id="{linkID}" href="{link}" class="{class}" target="{target}">{title}</a>
<div id="{descDivID}"">{description}>/div>
</div>
By default the code replaces {itemDivID} with "item0", {linkID} with "link0" and
{descDivID} with "desc0" (incrementing the 0 for each item displayed). That may be enough,
but if you are using more than one data stream on a page, you want your ID's to be unique. This
parameter allows you to tack a prefix on the front of each ID of each element for a data
stream. The prefix can be anything you like.
Example usage:
<?php
$params[streamID] = "110000003";
$params[maxitems] = "10";
$params[template] = "your_template.inc";
$params[dividprefix] = "ME";
displayItems($params);
?>
The above would output your template with element IDs of "MEitem0", "MElink0" and "MEdesc0"
for the first item, "MEitem1", "MElink1" and "MEdesc1" for the nxt item, etc etc.
This technique is used in the Style Library, which uses several
data streams on one page, and specifically to control the "Show/hide style code" links.
[top]
Outputting Data Streams As RSS
It is possible to create affCAFF data streams (incl. merged streams) and
output them as RSS. This is done in the normal way but using the "RSS Format" template and
an "outputformat" parameter. This is described on the affCAFF and Blogs
page in more detail.
[top]
Using CRON To Retrieve Data Streams
If you are of a technical nature, and have access to run CRON jobs, you will find the following
procedure more economical and efficient for retreiving data streams, but only attempt this
if you are familiar with running CRON jobs.
By nature, the data streams are retrieved to your site once a day within the "acFunctions.php"
include file. The first visitor to your site each day on a page where you call a specific
data stream, triggers the (background) retrieval of the latest data for that property.
Using CRON is more efficient, and gives you control over when you want the latest data
streams to be picked up. In your install directory, you will see a file "acCron.php".
This script can be set up to run once daily only to retrieve all of the feeds for properties
that you have set up affiliate links for (via your affCAFF Manager pages).
If you set up the CRON job, you must change the "Default Setting" (via affCAFF Manager) for
"CRON Data Stream Retrieval" to "Y". You must not move
this script from your affCAFF installation directory - CRON should call it from here.
You only need to set up one CRON job to run once a day - it will check for all the
streams you require on your site and get all the latest versions in one hit. Once done, and
assuming you have changed the Default Setting specified above to "N", this the user-triggered
retrieval of streams from the affCAFF server will cease, to be replaced with the once-daily retrieval
via CRON.
|