shortlink to ucp main subscribed bookmarks draft attachments

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
alex75
Registered User
Posts: 342
Joined: Sun Jun 10, 2012 9:09 am
Location: Italy
Name: Alessandro
Contact:

shortlink to ucp main subscribed bookmarks draft attachments

Post by alex75 » Wed Aug 15, 2018 11:51 am

Hello guys. as a title, I can not find the short link to ucp_main, for subscriptions, for bookmarks, for drafts, for attachments. I tried to use {U_UCP_MAIN_BOOKMARKS} and the like but it does not exist ... Thanks to those who will answer me.
screen.jpg

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51433
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: shortlink to ucp main subscribed bookmarks draft attachments

Post by Brf » Wed Aug 15, 2018 2:12 pm

If you are looking for template tags for navigation links in a Control Panel, there aren't any.
Those are built up by the <a href="{t_block2.U_TITLE}"><span>{t_block2.L_TITLE}</span></a> section in ucp_header.html.

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

Re: shortlink to ucp main subscribed bookmarks draft attachments

Post by alex75 » Wed Aug 15, 2018 4:06 pm

Many thanks.

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

Re: shortlink to ucp main subscribed bookmarks draft attachments

Post by alex75 » Thu Aug 16, 2018 12:21 am

I created the new shortlinks. they work properly, but I'm not convinced I did well.
I used a different 'core' for each new link. I think I could use the 'core.page_header' for all the links. Do you confirm me? here is the code I am using in the listener.php file:

Code: Select all

static public function getSubscribedEvents()
	{
		return array(
			'core.user_setup'	=> 'load_language',
			'core.page_header'	=> 'build_url_top', 
			'core.page_header_after'	=> 'build_url_drafts',
			'core.page_footer'	=> 'build_url_bookmarks',
			'core.page_footer_after'	=> 'build_url_subscribed',
			'core.obtain_users_online_string_modify' => 'build_url_attachments',
		);
	}

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51433
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: shortlink to ucp main subscribed bookmarks draft attachments

Post by Brf » Thu Aug 16, 2018 12:24 pm

I have no clue what you are trying to say, since those are not links -- they are events -- which are completely different.

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

Re: shortlink to ucp main subscribed bookmarks draft attachments

Post by alex75 » Thu Aug 16, 2018 6:03 pm

that's just part of the code for my extension. it's just for example. I asked if it was correct to use 1 core to create the event of each link. or if it was possible to use 1 core for all 4 links?
I wrote 4 events for 4 links like this:

Code: Select all

'core.page_header'	=> 'build_url_top', 
'core.page_header_after'	=> 'build_url_drafts,
'core.page_footer'	=> 'build_url_bookmarks',
'core.page_footer_after'	=> 'build_url_subscribed',

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1972
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: shortlink to ucp main subscribed bookmarks draft attachments

Post by kinerity » Thu Aug 16, 2018 7:10 pm

Maybe if you shared your code we could help you. Do you have a GitHub link?
Kailey Truscott - Community Team

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

Re: shortlink to ucp main subscribed bookmarks draft attachments

Post by alex75 » Thu Aug 16, 2018 7:38 pm

This is my listener.php
The code is working. I only ask if it's correct.

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;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class listener implements EventSubscriberInterface
{

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


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


	static public function getSubscribedEvents()
	{
		return array(
			'core.user_setup'	=> 'load_language',
			'core.page_header'	=> 'build_url_top', 
			'core.page_header_after'	=> 'build_url_drafts',
			'core.page_footer'	=> 'build_url_bookmarks',
			'core.page_footer_after'	=> 'build_url_subscribed',
			'core.obtain_users_online_string_modify' => 'build_url_attachments',
		);
	}


	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 build_url_top($event)
	{
		$params  = "author=" . $this->user->data['username'] . "&amp;sf=firstpost&amp;sr=topics";
		$url = append_sid($this->root_path . "search." . $this->phpEx, $params);
		$this->template->assign_vars(array(
			'U_WBYOURTOPICS'		=> $url,
		));
	}
	
	public function build_url_drafts($event)
	{
		$params  = "i=ucp_main&amp;mode=drafts";
		$url = append_sid($this->root_path . "ucp." . $this->phpEx, $params);
		$this->template->assign_vars(array(
			'U_WBYOURDRAFTS'		=> $url,
		));
	}
	
	public function build_url_subscribed($event)
	{
		$params  = "i=ucp_main&amp;mode=subscribed";
		$url = append_sid($this->root_path . "ucp." . $this->phpEx, $params);
		$this->template->assign_vars(array(
			'U_WBYOURSUBSCRIBED'		=> $url,
		));
	}
	
	public function build_url_bookmarks($event)
	{
		$params  = "i=ucp_main&amp;mode=bookmarks";
		$url = append_sid($this->root_path . "ucp." . $this->phpEx, $params);
		$this->template->assign_vars(array(
			'U_WBYOURBOOKMARKS'		=> $url,
		));
	}
	
	public function build_url_attachments($event)
	{
		$params  = "i=ucp_attachments&amp;mode=attachments";
		$url = append_sid($this->root_path . "ucp." . $this->phpEx, $params);
		$this->template->assign_vars(array(
			'U_WBYOURATTACHMENTS'		=> $url,
		));
	}
}

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

Re: shortlink to ucp main subscribed bookmarks draft attachments

Post by 3Di » Thu Aug 16, 2018 9:16 pm

Code: Select all


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

	/**
	 * Execute code and/or overwrite page_header()
	 *
	 * @event core.page_header
	 *
	 * Synopsys: Template switches over all
	 *
	 * @return void
	 * @access public
	 */
	public function build_urls($event)
	{
		$url_1 = append_sid($this->root_path . 'search.' . $this->phpEx, 'author=' . $this->user->data['username'] . '&amp;sf=firstpost&amp;sr=topics');

		$url_2 = blah;

		//Etc etc

		$this->template->assign_vars(array(
			'U_WB_YOUR_TOPICS'		=> $url_1,
			'U_WB_YOUR_DRAFTS'		=> $url_2,
			'U_WB_YOUR_SUBSCRIBED'		=> $url_3,
			'U_WB_YOUR_BOOKMARKS'		=> $url_4,
			'U_WB_YOUR_ATTACHMENTS'		=> $url_5,
		));
	}
:game_die: The new Dice Roller extension for phpBB 3.2 is out! :game_die:

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

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

Re: shortlink to ucp main subscribed bookmarks draft attachments

Post by alex75 » Thu Aug 16, 2018 9:36 pm

Many thanks. I meant exactly this (use only core_page_header for all the links to be created). it works perfectly.

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: No registered users and 9 guests