shortlink to ucp main subscribed bookmarks draft attachments

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

shortlink to ucp main subscribed bookmarks draft attachments

Post by alex75 »

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: 53379
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 »

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: 509
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 »

Many thanks.
User avatar
alex75
Registered User
Posts: 509
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 »

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: 53379
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 »

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: 509
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 »

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
Kailey
Community Team Leader
Community Team Leader
Posts: 3726
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Re: shortlink to ucp main subscribed bookmarks draft attachments

Post by Kailey »

Maybe if you shared your code we could help you. Do you have a GitHub link?
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules

If you have any questions about the rules/customs of this website, feel free to send me a PM.
User avatar
alex75
Registered User
Posts: 509
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 »

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
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: shortlink to ucp main subscribed bookmarks draft attachments

Post by 3Di »

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,
		));
	}
🆓 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 to ucp main subscribed bookmarks draft attachments

Post by alex75 »

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”