shortlink sitename in language file

Discussion forum for Extension Writers regarding Extension Development.
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: shortlink sitename in language file

Post by 3Di »

You should follow an order:

Code: Select all

services:
    alex75.welcomeback.listener:
        class: alex75\welcomeback\event\listener
        arguments:
            - '@user'
            - '@config'
            - '@template'
            - '%core.root_path%'
            - '%core.php_ext%'
            - '@language'
        tags:
            - { name: event.listener }
and purge cache again.

https://area51.phpbb.com/docs/dev/3.2.x ... -injection
The arguments are the service dependencies required by the class. It is important that the order of arguments must match the order of parameters in the __construct() method definition.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
alex75
Registered User
Posts: 509
Joined: Sun Jun 10, 2012 9:09 am
Location: Italy
Name: Alessandro
Contact:

Re: shortlink sitename in language file

Post by alex75 »

I have reorganized the file services and purge the cache...

Code: Select all

services:
    alex75.welcomeback.listener:
        class: alex75\welcomeback\event\listener
        arguments:
            - '@user'
            - '@template'
            - '%core.root_path%'
            - '%core.php_ext%'
            - '@config'
            - '@language'
        tags:
            - { name: event.listener }
Catchable fatal error: Argument 2 passed to alex75\welcomeback\event\listener::__construct() must be an instance of phpbb\config\config, instance of phpbb\template\twig\twig given in C:\xampp\htdocs\phpbbstoreit\ext\alex75\welcomeback\event\listener.php on line 27
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: shortlink sitename in language file

Post by 3Di »

read my post above.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
alex75
Registered User
Posts: 509
Joined: Sun Jun 10, 2012 9:09 am
Location: Italy
Name: Alessandro
Contact:

Re: shortlink sitename in language file

Post by alex75 »

3Di wrote: Sat Aug 18, 2018 9:53 pm read my post above.
ok now no error... but template not replace the string sitename.
i have
welcomeback on %s
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: shortlink sitename in language file

Post by 3Di »

post your template and lang files.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
alex75
Registered User
Posts: 509
Joined: Sun Jun 10, 2012 9:09 am
Location: Italy
Name: Alessandro
Contact:

Re: shortlink sitename in language file

Post by alex75 »

my lang file:

Code: Select all

<?php
/** 
* 
* @package welcome back
* @copyright (c) 2015 alex75 https://www.phpbb-store.it
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 
* 
*/ 
if (!defined('IN_PHPBB'))
{
exit;
}
if (empty($lang) || !is_array($lang))
{
$lang = array();
}
$lang = array_merge($lang, array(
'WELCOMEBACK_ON'			=> 'Welcome back on %s',
'WELCOMEBACK_HI'			=> 'Hi',
'WELCOMEBACK_SEE'			=> 'Nice to see you here',
'WBMY_TOPICS'				=> 'Your Topics',
'YOUR_SUBSCRIBED'			=> 'Your subscribed',
'YOUR_BOOKMARKS'			=> 'Your bookmarks',
'YOUR_DRAFTS'		    	=> 'Your drafts',
'YOUR_ATTACHMENTS'		   	=> 'Your attachments',
'IN_THIS_FORUM'		    	=> 'In this forum',
'IN_THIS_TOPIC'		    	=> 'In this topic',
'YOU_ARE_HERE'		    	=> 'You are here',
));
in the template, we call the {L_WELCOMEBACK_ON} string
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: shortlink sitename in language file

Post by 3Di »

Try and replace your whole listener file with this.

Code: Select all

<?php
/**
*
* @package welcome back
* @copyright (c) 2015 alex75 https://www.phpbb-store.it
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

namespace alex75\welcomeback\event;

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

/**
 * welcome back Event listener.
 */
class listener implements EventSubscriberInterface
{

	protected $user;
	protected $template;
	protected $root_path;
	protected $phpEx;
	protected $config;
	protected $language;

	public function __construct(
		\phpbb\user $user,
		\phpbb\config\config $config,
		\phpbb\template\template $template,
		$root_path,
		$phpEx,
		\phpbb\language\language $language)
	{
		$this->user			= $user;
		$this->config		= $config;
		$this->template		= $template;
		$this->root_path	= $root_path;
		$this->phpEx		= $phpEx;
		$this->language		= $language;
	}

	static public function getSubscribedEvents()
	{
		return array(
			'core.user_setup'	=> 'load_language',
			'core.page_header'	=> 'wb_tpl_vars', 
		);
	}

	public function load_language($event)
	{
		$lang_set_ext = $event['lang_set_ext'];
		$lang_set_ext[] = array(
			'ext_name' => 'alex75/welcomeback',
			'lang_set' => 'welcomebacklang',
		);
		$event['lang_set_ext'] = $lang_set_ext;
	}

	public function wb_tpl_vars($event)
	{
		$url_1 = append_sid($this->root_path . 'search.' . $this->phpEx, 'author=' . $this->user->data['username'] . '&amp;sf=firstpost&amp;sr=topics');
		$url_2 = append_sid($this->root_path . "ucp." . $this->phpEx, "i=ucp_main&amp;mode=drafts");
		$url_3 = append_sid($this->root_path . "ucp." . $this->phpEx, "i=ucp_main&amp;mode=subscribed");
		$url_4 = append_sid($this->root_path . "ucp." . $this->phpEx, "i=ucp_main&amp;mode=bookmarks");
		$url_5 = append_sid($this->root_path . "ucp." . $this->phpEx, "i=ucp_attachments&amp;mode=attachments");

		$this->template->assign_vars(array(
			'U_WBYOURTOPICS'		=> $url_1,
			'U_WBYOURDRAFTS'		=> $url_2,
			'U_WBYOURSUBSCRIBED'	=> $url_3,
			'U_WBYOURBOOKMARKS'		=> $url_4,
			'U_WBYOURATTACHMENTS'	=> $url_5,
			'WB_SITENAME'			=> $this->language->lang('WELCOMEBACK_ON', $this->config['sitename']),
		));
	}
}
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
alex75
Registered User
Posts: 509
Joined: Sun Jun 10, 2012 9:09 am
Location: Italy
Name: Alessandro
Contact:

Re: shortlink sitename in language file

Post by alex75 »

no difference. thanks for your patience.
I believe the error is here:

Code: Select all

'WELCOMEBACK_ON'			=> 'Welcome back on %s',
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: shortlink sitename in language file

Post by 3Di »

{L_WELCOMEBACK_ON} should be {WB_SITENAME} in the template
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
alex75
Registered User
Posts: 509
Joined: Sun Jun 10, 2012 9:09 am
Location: Italy
Name: Alessandro
Contact:

Re: shortlink sitename in language file

Post by alex75 »

Yes! finally it works! many thanks ;-)
User avatar
alex75
Registered User
Posts: 509
Joined: Sun Jun 10, 2012 9:09 am
Location: Italy
Name: Alessandro
Contact:

Re: shortlink sitename in language file

Post by alex75 »

Today I learned so many new rules. Thanks to @3Di , @david63 , @GanstaZ.
Here http://www.phpbb-store.it/test/ you can see the working welcomeback (for logged users. see the username and password in header).
Now I will send to the validation team my extension for phpbb 3.2.x if you want to preview the sending in mp ;-)
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: shortlink sitename in language file

Post by 3Di »

If you wish someone to admire your work then place your development extension into the dedicated forum, where you may receive opinions about it.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
alex75
Registered User
Posts: 509
Joined: Sun Jun 10, 2012 9:09 am
Location: Italy
Name: Alessandro
Contact:

Re: shortlink sitename in language file

Post by alex75 »

The forum I mentioned earlier is test-only and should not be registered; username and password are written on the header.
The extension for phpbb 3.1.x is already public on the CDB. this change is for phpbb 3.2.x. Yesterday I sent the new package pending validation.
Thanks again for your help.
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: shortlink sitename in language file

Post by david63 »

It would help in the future if you used GitHub (or similar) so that we can see the full picture and save time
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
alex75
Registered User
Posts: 509
Joined: Sun Jun 10, 2012 9:09 am
Location: Italy
Name: Alessandro
Contact:

Re: shortlink sitename in language file

Post by alex75 »

david63 wrote: Mon Aug 20, 2018 10:38 am It would help in the future if you used GitHub (or similar) so that we can see the full picture and save time
Here she is. Uploaded now on github for you.
Next time I'll upload it before asking for help. ;-)
https://github.com/phpbb-store/alex75-welcomeback
Post Reply

Return to “Extension Writers Discussion”