phpAdsNew  Home 

 

 

 

  4.2 How to determine which banner is displayed  

 

After you have added the banner code to your website you will probably notice it randomly select a banner from all the banners which are available. It doesn't matter what size the banner is or to which clients the banner belongs.

To narrow the group of banners where phpAdsNew chooses from you can configure each type of banner code with the what parameter. There a dozens of different ways to configure the what parameter, from very easy using zones, to very complicated and powerful using conditional keywords and parts.

 
  
  4.2.1 Zones  

 


Zones are groups of banners and can be configured using the admin interface. Zones have specific dimensions and can include banners from all clients and campaigns. If you want to add a specific banner to a specific zone you can simply go to the 'Linked Zones' page of each banner and select the zones you want to link this banner to.

For example: You have three different types of locations where you want to display banner. The first location would be on the main page, where you want to display one set of banners. The second location would be on the top of all the other pages. The third location would be on the bottom of your forum. The easiest way to solve this would be to create 3 zones, 1 for each different type of location. You can now determine which banners are displayed for each different type of location, simply by linking the banners to specific zones. If you want to show a banner on the forum only, you can simply link that banner to the third zone only. If you want to show another banner on all the pages except for the forum, just link the banner to the first and second zone.

Each zone has an unique ID, which can be used to select a zone from the banner code. If you need to know the unique ID of a specific zone, just go to the zone overview and look in the ID column.

zone:{id}
To show only banner from a specific zone you need to add the word 'zone', followed by a colon and the ID of the zone to the what parameter. If you want you can simply use the Invocation code generator from the admin interface, which will automatically add the correct parameters to the banner code.

view("zone:3");
  Display banners from zone 3 using local mode

<a href="adclick.php"><img src="adview.php?what=zone:3"></a>
  Display banners from zone 3 using remote invocation

 

 
   
  4.2.2 Keywords or size  

 


Although zones are very easy to administer using the the admin interface it is also possible to determine which banners are displayed directly with the banner code. The "what" parameter is a very powerful method of selecting the right banner you want to display, but if you want to keep it simple the 'what' parameter can also be very easy to use.


Selecting a banner by keyword
If you want to display a banner with a specific keyword you can simply specify that keyword as the 'what' parameter.

view("main");
  Display a banner with the keyword 'main'

<a href="adclick.php"><img src="adview.php?what=key1"></a>
  Display a banner with the keyword 'key1'

It is also possible to specify multiple keywords as the 'what' parameter, separated by a comma (,). phpAdsNew will try to display a banner with one of these keywords. The banner only needs to contain one of the specified keywords to be considered a good match, it doesn't have to contain all the specified keywords.

view("main,top2");
  Display a banner with the keyword 'main' or 'top2'


Selecting a banner by size
If you need the banner to be a specific size you can specify the size as the 'what' parameter

view("120x120");
  Display a banner with width 120 and height 120

<a href="adclick.php"><img src="adview.php?what=468x60"></a>
  Display a banner with width 468 and height 60

 

 
  
  4.2.3 Advanced options  

 


If you want to tap in to power of the 'what' parameter and start using expressions, logical operators and different statements, please read the following section very careful.

 

Expressions
The "what" parameter can consist of one or more expressions. Each expression will be executed when the previous expression has failed. Multiple expression must be separated with the character | and may not be separated by spaces.

If you don't provide an expression and leave the "what" parameter empty phpAdsNew match any active banner and will display one randomly.

For example if the first expression does not match any banner the second expression will be executed. If the second expression does not match any banner the third expression will be executed. This also means that if the first expression does match a banner, the second and third expression won't be executed.
You can specify as much expressions as you like, but each additional expression may require some extra system resources, such a processing time and database queries.

RIGHT: expression1

RIGHT: expression1|expression2|expression3

WRONG: expression1 | expression2

 

Logical operators
Each expression can consist of one or more statements. Each statement tries to match one or more banners. The simplest expression would only consist of one statement. phpAdsNew will try to find a banner that matches this statement. However, it is possible to use multiple statements and use logical operators.

The logical operators look a bit different than the ones used in MySQL and PHP, but work the same way.

Statements need to be separated by a comma (,) and a statement can begin with a switch to set the behavior. Do not put a space between the operator and the statement.

If you separate statements without a switch, the separator will become an OR operator.

statement,statement
  Meaning: statement OR statement

If you use the + or _ switch the separator will become an AND operator. Please note: you can't use the + switch in remote invocation and must use the _ switch, which means exactly the same.

statement,+statement
statement,_statement
  Meaning: statement AND statement

If you use the - switch the separator will become a NOT operator. You can use the - switch on the first statement.

statement,-statement
  Meaning: statement NOT statement

-statement,-statement
  Meaning: NOT statement NOT statement

For example

statement1,statement2,statement3
  Meaning: statement1 OR statement2 OR statement3

statement1,+statement2,+statement3
  Meaning: statement1 AND statement2 AND statement3

statement1,+statement2,-statement3
  Meaning: statement1 AND statement2 NOT statement3

OR takes precedence over AND and NOT. AND and NOT have equal precedence. At this moment it is not possible to use parentheses to force precedence!

For example:

statement1,+statement2,statement3
  Meaning: (statement1 AND statement2) OR statement3

statement1,+statement2,statement1,+statement3
  Meaning: (statement1 AND statement2) OR (statement1 AND statement3)
  Meaning: statement1 AND (statement2 OR statement3)

statement1,statement2,-statement3
  Meaning statement1 OR (statement2 NOT statement3)

statement1,-statement3,statement2,-statement3
  Meaning (statement1 NOT statement3) OR (statement2 NOT statement3)
  Meaning (statement1 OR statement2) NOT statement3

 

Statements
Each statement tries to match a specific property of the available banners.


bannerid:[digits] or [digits]

You can match a banner by looking at the banner ID property. phpAdsNew will try to find a banner with an ID equal to the digits you specified.

1
  Match a banner with ID 1

bannerid:23
  Match a banner with ID 23


clientid:[digits]

You can match a banner by looking at the ID of the owner of the banner. phpAdsNew will try to find a banner, which owner's ID is equal to the digits you specified.

clientid:32
  Match a banner which owner had ID 32


[width]x[height]

You can match a banner by looking at the dimension of the banner. phpAdsNew will try to find a banner with the same width and height you specified.

468x60
  Match a banner with width 468 and height 60


width:[digits]

It is also possible to match only by looking at the width of the banner, which could be very useful if you want to try and build a vertical banner-bar.

width:120
  Match a banner with width 120


format:[type] or html

You can match a banner by looking at the banner format. phpAdsNew will try to find a banner with the same format as the type you specified. If you want to match html banners you can use a shortcut and specify only 'html'.

format:html
  Match a banner of type HTML

html
  Match a banner of type HTML


[keyword]

You can match a banner by looking at the keywords of the banner. phpAdsNew will try to find a banner with the keyword you specified. You can use digits in your keywords, but every keyword must contain at least one character other than a digit or an 'x'. You can't use a colon (:) in your keywords.

mybanners
  Match a banner with keyword "mybanners"

frontpage
  Match a banner with keyword "frontpage"

 

The global keyword
In phpAdsNew you can define global banners. You can add the "global" keyword to your banners through the admin interface. Every banner with the "global" keyword will be considered a match.

The behavior only works if you are using one expression with only keywords. Otherwise you will have to add the "global" keyword to the expressions by hand.

key1
  Meaning: Match a banner with keyword "key1" or "global"

key1|key2,global
  Meaning: Match a banner with the keyword "key1". If there are no banners
  with this keyword try to match a banner with keyword "key2" or "global"

key1|global
  Meaning: Match a banner with the keyword "key1". If there are no matching
  banners, match a banner with keyword "global"

 

Creating a fail-safe
In certain conditions you may want to automatically generate keywords and add these to your expression, for example:

$weekday = date("w"); // 0=Sunday, 1=Monday, etc.
view ("day$weekday");

The above example will try to display a different banner for each day of the week. On Sunday it will try to display a banner with the keyword "day0", on Monday it will try to display a banner with the keyword "day1", etc.
However if you didn't define banners any banner with the keyword "day3". phpAdsNew will not show any banners on Wednesday. You may want to create a fail-safe. If there are no banners available for a certain day you want to display a general banner. You could add some new banners and assign the keyword "general" to them. And use a construction like this:

$weekday = date("w"); // 0=Sunday, 1=Monday, etc.
view ("day$weekday|general");

The above example will try to display a banner for each day of the week, but if it can't find any banners on a specific day it will try to display a banner with the keyword "general".

 

Examples

key1|main
  Match a banner with keyword "key1". If there are no banners with
  this keyword try to match a banner with keyword "main"

key1,key2|clientid:3
  Match a banner with keyword "key1" or "key2". If there are no banners
  with this keyword try to match a banner with client id 3

key1,-clientid:2
  Match a banner with keyword "key1", don't match banners with clientid 2.

4|clientid:2,clientid:4|key1|global
  Match a banner with id 4. If there are no matching banners try to match a
  banner with client id 2 or 4. If there are no matching banners try to match
  a banner with keyword "key1". If there are no matching banners try to match
  a banner with keyword "global".

html,+key1,+key2,-clientid:2
  Match a html banner with keyword "key1" and "key2", but don't match banners
  from client with ID 2.

3,+468x60,4,+468x60,5,+468x60
  Match a banner with a width of 468 and a height of 60.
  The banner ID must be 3, 4 or 5.

key1,-468x60,key2,-468x60
  Match a banner with keyword "key1" or "key2".
  The banner must not have a width of 468 and a height of 60