Jump to content

Developer Documentation

core/Announcements

What it does

Announcement extensions allow your applications to show announcements in specific areas of the application, e.g. showing announcements in a specific category or section of your application. When the extension is available, while creating or editing announcements moderators will be able to configure the announcement based on your specifications (for instance, to select one or more categories).

How to use

Upon creating a new instance of this extension in the developer center, the template file will contain one method and two class properties that you can adjust. The first class property specifies the database column (without the table prefix defined in your model class) to look for the container ID

public static $idField = "id";

The second property allows you to specify which controllers within your application the announcement should be displayed within. You can use this, for example, to only show announcements within the container and not when viewing the content items within those containers.

public static $controllers = array( "browse" );

The sole method in this extension allows you to return a form element which will allow the moderator to choose which categories (corresponding to the $idField property) the announcement should be shown within. You will generally be returning an instance of \IPS\Helpers\Form\Node here.

    public function getSettingField( $announcement )
    {
        return new \IPS\Helpers\Form\Node( 'announce_download_categories', ( $announcement AND $announcement->ids ) ? explode( ",", $announcement->ids ) : 0, FALSE, array( 'class' => 'IPS\downloads\Category', 'zeroVal' => 'any', 'multiple' => TRUE ), NULL, NULL, NULL, 'announce_download_categories' );
    }

That's all there is to it. The announcement widget handles the rest by checking the requested content item and/or node ID against the configuration for individual announcements to ensure that they only show up where configured.


  Report Document


×
×
  • Create New...