[Extension Support] Personal Extension

Support for PhpBB3.
Post here to get help with any phpBB3 related issue
Forum rules
In order the get any support, you will have to do following:
1. Use a describing title!
2. Describe your problem and what happened when the problem occured
3. Tell us what version of phpBB3 you are currently using.
If not your topic may be ignored or locked!

[Extension Support] Personal Extension

Post by cisco007 »

I have just started back into phpbb, and i had an extension that only had template injections, and css injections. but i was wondering what file do i make or edit to have it inject my ext's language file? i tried using the skeleton extension maker, but as soon as i enable the extension and refresh my board goes blank so i deleted it and wanted to start again? @Stoker @Steve any help?

[Extension Support] Personal Extension

Post by SpIdErPiGgY »

You need to add that in /event/listener.php
Something like:

Code: Select all

	public function load_language_on_setup($event)
	{
		$lang_set_ext = $event['lang_set_ext'];
		$lang_set_ext[] = array(
			'ext_name' => 'solidjeuh/boardmagic',
			'lang_set' => 'common',
		);
		$event['lang_set_ext'] = $lang_set_ext;
	}
Complete example:

Code: Select all

namespace solidjeuh\boardmagic\event;

/**
* @ignore
*/
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* Event listener
*/
class listener implements EventSubscriberInterface
{
	/** @var \phpbb\config\config */
	protected $config;
	/** @var \phpbb\template\template */
	protected $template;

	/**
	* Constructor
	*
	* @param \phpbb\config\config		$config
	* @param \phpbb\template\template	$template
	*
	*/
	public function __construct(\phpbb\config\config $config, \phpbb\template\template $template)
	{
		$this->config = $config;
		$this->template = $template;
	}

	static public function getSubscribedEvents()
	{
		return array(
			'core.user_setup'		=> 'load_language_on_setup',
			'core.page_footer'		=> 'page_footer',
		);
	}

	public function load_language_on_setup($event)
	{
		$lang_set_ext = $event['lang_set_ext'];
		$lang_set_ext[] = array(
			'ext_name' => 'solidjeuh/boardmagic',
			'lang_set' => 'common',
		);
		$event['lang_set_ext'] = $lang_set_ext;
	}

	public function page_footer($event)
	{
		$start_date = @gmdate('Y', $this->config['board_startdate']);
		$this->template->assign_vars(array(
			'L_COPYRIGHT_YEAR'			=> $start_date,
		));
	}
}

[Extension Support] Personal Extension

Post by cisco007 »

i thought i had it like it that, but i will check it and see. i'll keep you posted.

[Extension Support] Personal Extension

Post by cisco007 »

nah, i must be doing something wrong on the config/services.yml or on the event/listerner.php files.
i've uninstalled, deleted data, cleared the cache. used STK to uninstall extension, then reactivate it. and i still get a blank board

[Extension Support] Personal Extension

Post by Stoker »

What does your services look like?

[Extension Support] Personal Extension

Post by cisco007 »

Code: Select all

services:
   cisco.myaddons.listener:
        class: cisco\myaddons\event\listener
        arguments:
            - '@config'
            - '@template'
        tags:
            - { name: event.listener }
and my listener like this:

Code: Select all

<?php
/**
 *
 * myaddons. An extension for the phpBB Forum Software package.
 *
 * @copyright (c) 2025, cisco, http://phpbbmexico.com
 * @license GNU General Public License, version 2 (GPL-2.0)
 *
 */

namespace cisco\myaddons\event;

/**
* @ignore
*/
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* Event listener
*/
class listener implements EventSubscriberInterface
{
	/** @var \phpbb\config\config */
	protected $config;
	/** @var \phpbb\template\template */
	protected $template;

	/**
	* Constructor
	*
	* @param \phpbb\config\config		$config
	* @param \phpbb\template\template	$template
	*
	*/
	public function __construct(\phpbb\config\config $config, \phpbb\template\template $template)
	{
		$this->config = $config;
		$this->template = $template;
	}

	static public function getSubscribedEvents()
	{
		return array(
			'core.user_setup'		=> 'load_language_on_setup',
			'core.page_footer'		=> 'page_footer',
		);
	}

	public function load_language_on_setup($event)
	{
		$lang_set_ext = $event['lang_set_ext'];
		$lang_set_ext[] = array(
			'ext_name' => 'cisco/myaddons',
			'lang_set' => 'common',
		);
		$event['lang_set_ext'] = $lang_set_ext;
	}

	public function page_footer($event)
	{
		$start_date = @gmdate('Y', $this->config['board_startdate']);
		$this->template->assign_vars(array(
			'L_COPYRIGHT_YEAR'			=> $start_date,
		));
	}
}