shortlink sitename in language file

Discussion forum for Extension Writers regarding Extension Development.
User avatar
3Di
Registered User
Posts: 12885
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: shortlink sitename in language file

Post by 3Di » Sat Aug 18, 2018 9:46 pm

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.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
alex75
Registered User
Posts: 329
Joined: Sun Jun 10, 2012 9:09 am
Location: Italy
Name: Alessandro
Contact:

Re: shortlink sitename in language file

Post by alex75 » Sat Aug 18, 2018 9:50 pm

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
Registered User
Posts: 12885
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: shortlink sitename in language file

Post by 3Di » Sat Aug 18, 2018 9:53 pm

read my post above.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
alex75
Registered User
Posts: 329
Joined: Sun Jun 10, 2012 9:09 am
Location: Italy
Name: Alessandro
Contact:

Re: shortlink sitename in language file

Post by alex75 » Sat Aug 18, 2018 10:02 pm

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
Registered User
Posts: 12885
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: shortlink sitename in language file

Post by 3Di » Sat Aug 18, 2018 10:04 pm

post your template and lang files.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
alex75
Registered User
Posts: 329
Joined: Sun Jun 10, 2012 9:09 am
Location: Italy
Name: Alessandro
Contact:

Re: shortlink sitename in language file

Post by alex75 » Sat Aug 18, 2018 10:10 pm

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
Registered User
Posts: 12885
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: shortlink sitename in language file

Post by 3Di » Sat Aug 18, 2018 10:15 pm

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']),
		));
	}
}
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
alex75
Registered User
Posts: 329
Joined: Sun Jun 10, 2012 9:09 am
Location: Italy
Name: Alessandro
Contact:

Re: shortlink sitename in language file

Post by alex75 » Sat Aug 18, 2018 10:22 pm

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

Code: Select all

'WELCOMEBACK_ON'			=> 'Welcome back on %s',

User avatar
3Di
Registered User
Posts: 12885
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: shortlink sitename in language file

Post by 3Di » Sat Aug 18, 2018 10:26 pm

{L_WELCOMEBACK_ON} should be {WB_SITENAME} in the template
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
alex75
Registered User
Posts: 329
Joined: Sun Jun 10, 2012 9:09 am
Location: Italy
Name: Alessandro
Contact:

Re: shortlink sitename in language file

Post by alex75 » Sat Aug 18, 2018 10:31 pm

Yes! finally it works! many thanks ;-)

User avatar
alex75
Registered User
Posts: 329
Joined: Sun Jun 10, 2012 9:09 am
Location: Italy
Name: Alessandro
Contact:

Re: shortlink sitename in language file

Post by alex75 » Sat Aug 18, 2018 10:42 pm

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
Registered User
Posts: 12885
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: shortlink sitename in language file

Post by 3Di » Mon Aug 20, 2018 5:47 am

If you wish someone to admire your work then place your development extension into the dedicated forum, where you may receive opinions about it.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
alex75
Registered User
Posts: 329
Joined: Sun Jun 10, 2012 9:09 am
Location: Italy
Name: Alessandro
Contact:

Re: shortlink sitename in language file

Post by alex75 » Mon Aug 20, 2018 8:44 am

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
Jr. Extension Validator
Posts: 14638
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: shortlink sitename in language file

Post by david63 » 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
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
alex75
Registered User
Posts: 329
Joined: Sun Jun 10, 2012 9:09 am
Location: Italy
Name: Alessandro
Contact:

Re: shortlink sitename in language file

Post by alex75 » Mon Aug 20, 2018 10:59 am

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”

Who is online

Users browsing this forum: No registered users and 5 guests