Skip to content

Add avathar.recenttopicsav.modify_ads_code event to allow third-party ad content providers #175

@avandenberghe

Description

@avandenberghe

Background

Issue #160 added a built-in advertisement block to Recent Topics (ACP toggle + HTML textarea, rendered via ADS_INDEX_CODE in the index template). The pbwowext extension has had the same feature since earlier, also assigning ADS_INDEX_CODE via core.page_header.

Because core.index_modify_page_title (Recent Topics) fires after core.page_header (pbwowext), Recent Topics currently overwrites pbwowext's assignment silently. There is no way for pbwowext to act as a content provider for the ad block without this race condition.

Proposal

Fire a new PHP event avathar.recenttopicsav.modify_ads_code in core/recenttopics.php just before assigning ADS_INDEX_CODE to the template.

$vars = ['ads_index_code'];
extract($this->dispatcher->trigger_event('avathar.recenttopicsav.modify_ads_code', compact($vars)));
  • ads_index_code is pre-populated with Recent Topics' own configured value (from rt_ads_enable / rt_ads_code), or false if disabled
  • A listener can read and override ads_index_code to inject content from another source
  • If no listener overrides it, behaviour is identical to today

Effect

  • pbwowext can listen to this event and inject its own ad content, removing the need for it to assign ADS_INDEX_CODE directly in core.page_header
  • Any other extension can also use this event to provide ad content
  • Recent Topics' own ACP ad settings serve as the default when no listener overrides

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions