| 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 phpPgAds 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. phpPgAds 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. phpPgAds 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. phpPgAds
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. phpPgAds
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. phpPgAds 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. phpPgAds 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 phpPgAds 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".
phpPgAds 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 |
|
| |