Page 1 of 2
[Extension Support] Personal Extension
Posted: 19 Aug 2025, 21:23
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
Posted: 20 Aug 2025, 03:39
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
Posted: 20 Aug 2025, 10:49
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
Posted: 20 Aug 2025, 11:38
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
Posted: 20 Aug 2025, 12:39
by Stoker
What does your services look like?
[Extension Support] Personal Extension
Posted: 20 Aug 2025, 12:58
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,
));
}
}
[Extension Support] Personal Extension
Posted: 20 Aug 2025, 14:13
by Stoker
and you do have a lang file called common in cisco\myaddons\language\en (or es or both)?
[Extension Support] Personal Extension
Posted: 20 Aug 2025, 14:27
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
[Extension Support] Personal Extension
Posted: 20 Aug 2025, 14:39
by Stoker
Take a look at this version:
Its testet and working with lang file.
You can compare it to your own and see what went wrong
[Extension Support] Personal Extension
Posted: 20 Aug 2025, 15:38
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?