• WordPress Plugin – Block Rules

    von am 23. November 2008

    Block Rules is a simple WordPress plug-in that allows you to attach visibility rules to predefined template blocks. It is easy to use without additional programming effort. Out of the box there already is a set of rules that can simply be extended. The tool is currently available in version 1.0.0.1.

    Motivation

    Block rules was developed in the need of displaying a google adsense block only if a given posting was older than seven days, as we did not want to bother our readers, but people coming to our page using a search engine. Since all existing plug-ins were not able to do this, the idea came up to implement such a tool. After a while it was needed to display the same adsense block if a text was longer than 3000 characters. It was quite obvious to design the tool in a way it should be easy to extend the rules just implementing against an simple interface. Block rules was born and it is still used in this blog with the mentioned rules. Since we knew that we are not the only blog that needs such a plug-in we decided to release it under a creative commons license.

    Rules

    There is a set of rules that can be used out of the box and this set is growing fast, since everybody can easily write own rules. A list of all rules can be found in our rules section, as well as a how-to for creating new rules. At the moment following rules are existing: Posting older than, Text longer than and valid scope.

    Installation

    For installing Block Rules you have to download the current version from our server and copy it into the wordpress plugin directory, just like every other wordpress extension. Unfortunatelly it is not possible to create the needed database tables using the plugin installation trigger. Therefore you have to call the installation script manually using the following url:

    http://your-domain.tld/wp-content/plugins/BlockRules/installer.php

    This script will create the single table that is needed to run block rules. Now log in into the wordpress admin panel and activate the plug-in. Afterwards you can easily start creating your own rules. Now you can add a code block like this to your template:

    <?php if ( showBlock( 'adsense' ) ) { ?>
      <div> I am a block that is not always displayed </div>
    <?php } ?>

    This block will only be shown if all predefined rules, attached to the “adsense” block identifier, are applying.

    License

    Block rules is published under a creative commons license. Please feel free to extend the tool and publish it. If you write new rules please send a mail to blockrules@phphatesme.com and attach it, so we can add it in the next release. If you are extending block rules please add a link to this page.

    Release Notes

    Version Date Changes
    1.0.0.1 2008-11-24
    • Renamed tempBlock to showBlock
    1.0.0.0 2008-11-23
    • Initial Version
    Nils Langner

    Auch wenn Ihr es mir nicht glauben werdet, aber ich habe nichts gegen PHP. Ich rege mich einfach nur gerne auf. Ok so schlimm ist es auch nicht. Eigentlich wollte ich schon immer einen Blog haben und da ...

    Zum Profil von Nils Langner

    1 Kommentar »


    • Denis
      am 24. März 2009 um 17:20 Uhr

      Sehr nützlich, danke :)

      Aber der RSS-Link ist ziemlich versteckt ;)

    RSS Feed für Kommentare zu diesem Artikel.

    Hinterlasse einen Kommentar

    Werbung
    PHP Magazin
    Ausgabe 02/2010

    Dieses Mal mit Artikeln zu den Themen OpenSocial und Apache Shindig, Graphentheorie, Smarty3

    t3n
    Ausgabe 19

    Social Media (R)evolution. Weitere Themen sind noSQL, Crowdsourcing ...

    PHP Journal
    Ausgabe 2/2010

    PHP & Windows optimal nutzen, die besten PHP-CMS im Überblick, Google-API mit Zend Framework nutzen.

    Wir wurden schon öfters gefragt, ob man uns nicht irgendwie unterstützen kann. Die Antwort war immer einfach: Klar! Am einfachsten ist es eure nächsten Einkäufe bei Amazon über unsere Link abzuwickeln. Damit würdet ihr uns schon sehr helfen. Über Co-Autoren freuen wir uns aber noch mehr.