[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!
User avatar
cisco007 Offline
BBCoder VI
BBCoder VI
Posts: 1,049
Joined: 16 Mar 2010, 16:14
Local time: 04 Sep 2025 15:57
Last active: -
Location: Don't really know!

[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?
User avatar
SpIdErPiGgY Offline
Donator
Donator
Posts: 53
Joined: 13 Dec 2024, 08:43
Local time: 04 Sep 2025 21:57
Last active: -
Location: Erpe-Mere, Belgium
Contact:

[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,
		));
	}
}
User avatar
cisco007 Offline
BBCoder VI
BBCoder VI
Posts: 1,049
Joined: 16 Mar 2010, 16:14
Local time: 04 Sep 2025 15:57
Last active: -
Location: Don't really know!

[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.
User avatar
cisco007 Offline
BBCoder VI
BBCoder VI
Posts: 1,049
Joined: 16 Mar 2010, 16:14
Local time: 04 Sep 2025 15:57
Last active: -
Location: Don't really know!

[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
User avatar
Stoker Offline
Site Admin
Site Admin
Posts: 4,555
Joined: 12 May 2008, 21:26
Local time: 04 Sep 2025 21:57
Last active: -
Favourite EXT: Forum Goal
Location: Denmark
Contact:

[Extension Support] Personal Extension

Post by Stoker »

What does your services look like?
~ The greatest achievement in life is to inspire ~
Regards Stoker
User avatar
cisco007 Offline
BBCoder VI
BBCoder VI
Posts: 1,049
Joined: 16 Mar 2010, 16:14
Local time: 04 Sep 2025 15:57
Last active: -
Location: Don't really know!

[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,
		));
	}
}
User avatar
Stoker Offline
Site Admin
Site Admin
Posts: 4,555
Joined: 12 May 2008, 21:26
Local time: 04 Sep 2025 21:57
Last active: -
Favourite EXT: Forum Goal
Location: Denmark
Contact:

[Extension Support] Personal Extension

Post by Stoker »

and you do have a lang file called common in cisco\myaddons\language\en (or es or both)?
~ The greatest achievement in life is to inspire ~
Regards Stoker
User avatar
cisco007 Offline
BBCoder VI
BBCoder VI
Posts: 1,049
Joined: 16 Mar 2010, 16:14
Local time: 04 Sep 2025 15:57
Last active: -
Location: Don't really know!

[Extension Support] Personal Extension

Post by cisco007 »

yeah, something is wrong there i can't get it. if i remove the services.yml file it works, but i can't get the language variables needed.
To much reading here:

https://area51.phpbb.com/docs/dev/3.2.x ... vents.html
User avatar
Stoker Offline
Site Admin
Site Admin
Posts: 4,555
Joined: 12 May 2008, 21:26
Local time: 04 Sep 2025 21:57
Last active: -
Favourite EXT: Forum Goal
Location: Denmark
Contact:

[Extension Support] Personal Extension

Post by Stoker »

Take a look at this version:
addcss.zip
(13.57 KiB) Downloaded 2 times
Its testet and working with lang file.
You can compare it to your own and see what went wrong
~ The greatest achievement in life is to inspire ~
Regards Stoker
User avatar
cisco007 Offline
BBCoder VI
BBCoder VI
Posts: 1,049
Joined: 16 Mar 2010, 16:14
Local time: 04 Sep 2025 15:57
Last active: -
Location: Don't really know!

[Extension Support] Personal Extension

Post by cisco007 »

i just looked at my language file for some reason it had a [ instead of a (
and when i open your lang file notepad++ says yours is unix/ansi and mine is unix/utf8. isn't that what its supposed to be?
Post Reply