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
Background
Issue #160 added a built-in advertisement block to Recent Topics (ACP toggle + HTML textarea, rendered via
ADS_INDEX_CODEin the index template). The pbwowext extension has had the same feature since earlier, also assigningADS_INDEX_CODEviacore.page_header.Because
core.index_modify_page_title(Recent Topics) fires aftercore.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_codeincore/recenttopics.phpjust before assigningADS_INDEX_CODEto the template.ads_index_codeis pre-populated with Recent Topics' own configured value (fromrt_ads_enable/rt_ads_code), orfalseif disabledads_index_codeto inject content from another sourceEffect
ADS_INDEX_CODEdirectly incore.page_headerRelated