[[blocks]]
 

PHP Block How-To

PHP Blocks give you the power of letting a Geeklog block execute some code to generate dynamic output. To make it more secure, you are not allowed to add PHP code directly to the content of your block but, instead, must add a function to your /path/to/geeklog/lib-custom.php and then assign your PHP block to execute that function. To keep someone from executing arbitrary PHP functions we require PHP block functions to start with the phpblock_ prefix.

Once your function is called you have the full power of PHP at your disposal to do what ever you little heart desire.

Example

To drive the power of this home, let's try a real-world example. This example will put a “refer this site” form on your site so others can refer your Geeklog website to others.

1) First, code the function in your lib-custom.php (remember function name must start with phpblock_ prefix).

See Refer site

2) Create the PHP block via the Geeklog block administration page:

  • Click on the “New Block” link
  • Enter the block name, title, blockorder, side and be sure to select php_block from the block type drop-down
  • Scroll Down To PHP Block Options and enter the name of your function (for our example it would be phpblock_refer_site)
  • Assign appropriate permissions
  • Save it and you are done!

Other Information

The function in the code-sample stores the number of referrals made in the database. If you want to ever find out how many referrals you have or want to add this to your stats.php page the SQL you would need is: SELECT value FROM vars WHERE name = 'num_site_referrals'

Les blocks

Connecté en tant que : Guest (Guest)
blocks.txt · Dernière modification: 2011/07/04 15:03 par ::Ben
 

Download geeklog

Last version 1.8.1

Espace Membre





Devenir membre
Enregistrez-vous

Mot de passe oublié ?

Change language

Categories

  • Geeklog (38)
  • Plugins (53)
  • Thèmes (16)
  • My cart

    Votre panier (0 article)

    Votre panier est vide!

    0.00 EUR

    Visual Theme Switcher

    Test out available themes by selecting from one of the 6 available themes or give the Visual Switcher a try:

    Follow us on twitter

    En ligne

    Visiteurs: 8