ACP expressions

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
User avatar
Restless Rancor
Registered User
Posts: 196
Joined: Tue Sep 18, 2018 1:51 pm

ACP expressions

Post by Restless Rancor »

Hi, I've been using %sitename% in some text fields, but can't find one that displays the site URL.
In language/en/ucp.php I was able to find %1$s which refers to the site name and %2$s which refers to the URL, but can't find what expression I can use similar to %sitename% to load the URL. Is there a list of expressions someone has a link to please?
Thanks
These are not the droids you're looking for...
User avatar
Lumpy Burgertushie
Registered User
Posts: 69224
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: ACP expressions

Post by Lumpy Burgertushie »

please explain exactly what you are trying to do. the final outcome you want, not how you think it should/could be done.


robert
Premium phpBB 3.3 Styles by PlanetStyles.net

I am pleased to announce that I have completed the first item on my bucket list. I have the bucket.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53413
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: ACP expressions

Post by Brf »

Restless Rancor wrote: Tue Sep 18, 2018 1:56 pm I was able to find %1$s which refers to the site name and %2$s which refers to the URL,
Those symbols stand for "first string parameter" and "second string parameter". When those strings are used, the parameters are filled in from a variable. When the code calls sprintf($user->lang['TERMS_OF_USE_CONTENT'], $config['sitename'], generate_board_url()), it uses $config['sitename'] as the first parameter and calls generate_board_url() for the second.
User avatar
Restless Rancor
Registered User
Posts: 196
Joined: Tue Sep 18, 2018 1:51 pm

Re: ACP expressions

Post by Restless Rancor »

Lumpy Burgertushie wrote: Tue Sep 18, 2018 6:59 pm please explain exactly what you are trying to do. the final outcome you want, not how you think it should/could be done.


robert


Hi Robert,
In the terms of agreement (ucp.php?mode=terms) it uses %sitename% to display the site name, in this case "phpbb.com" and I would like to know what to use to display the site URL.

Using %sitename% means if I change the site name in board settings it'll update everywhere else, which is why I'd like to find the one for the site URL and a list of others if possible.
Just as an example, you can put %sitename% into a forum description to have the site name displayed there.
Hope that clears it up, thanks.
Last edited by Restless Rancor on Tue Sep 18, 2018 7:24 pm, edited 2 times in total.
These are not the droids you're looking for...
User avatar
Restless Rancor
Registered User
Posts: 196
Joined: Tue Sep 18, 2018 1:51 pm

Re: ACP expressions

Post by Restless Rancor »

Brf wrote: Tue Sep 18, 2018 7:14 pm
Restless Rancor wrote: Tue Sep 18, 2018 1:56 pm I was able to find %1$s which refers to the site name and %2$s which refers to the URL,
Those symbols stand for "first string parameter" and "second string parameter". When those strings are used, the parameters are filled in from a variable. When the code calls sprintf($user->lang['TERMS_OF_USE_CONTENT'], $config['sitename'], generate_board_url()), it uses $config['sitename'] as the first parameter and calls generate_board_url() for the second.

Hi Brf,
Thanks for explaining how those work, I thought I might be in the wrong place; language/en/ucp.php was the wrong place to be looking.
These are not the droids you're looking for...
User avatar
Restless Rancor
Registered User
Posts: 196
Joined: Tue Sep 18, 2018 1:51 pm

Re: ACP expressions

Post by Restless Rancor »

Hi, I'm still hoping to find an answer to this question. I'll try to explain it clearer.

In language/en/ucp.php the Terms of Service text begins with By accessing “%1$s” (hereinafter “we”, “us”, “our”, “%1$s”, “%2$s”). “%1$s” displays as the forum name and “%2$s” as the board URL.

In the ACP I am able to enter %sitename% for the site name to be displayed anywhere I put it. EG: Custom pages, forum descriptions etc.
I'd like to know what I could put to have the board URL to display. I'm unsure if %sitename% is something added by an extension or not.

This would be so I can enter these (wildcards??) and if the configuration is changed they'll automatically change and I won't have to update ever instance.

Thanks
These are not the droids you're looking for...
User avatar
GanstaZ
Registered User
Posts: 1187
Joined: Wed Oct 11, 2017 10:29 pm
Location: GZOverse

Re: ACP expressions

Post by GanstaZ »

What do you mean by board url? There's root parameter => ./ or ./forum/ or ./phpbb, there are pages like index, viewtopic (+ different extra params) and so on and there are main phpbb/or extension routes ?app.php/something or root/help/faq (depends on urlrewrite).
Usus est magister optimus! phpBB pre-Triton & latest php environment.
When answer lies in the question, question becomes redundant!
User avatar
Restless Rancor
Registered User
Posts: 196
Joined: Tue Sep 18, 2018 1:51 pm

Re: ACP expressions

Post by Restless Rancor »

GanstaZ wrote: Tue Sep 25, 2018 1:32 pm What do you mean by board url? There's root parameter => ./ or ./forum/ or ./phpbb, there are pages like index, viewtopic (+ different extra params) and so on and there are main phpbb/or extension routes ?app.php/something or root/help/faq (depends on urlrewrite).
Hi, I mean simply the board root.
These are not the droids you're looking for...
User avatar
GanstaZ
Registered User
Posts: 1187
Joined: Wed Oct 11, 2017 10:29 pm
Location: GZOverse

Re: ACP expressions

Post by GanstaZ »

Board root is defined for example in index file:

Code: Select all

$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
And it can be used in any extension via injected (symfony container) parameter (service .yml file):

Code: Select all

services:
    serive_name:
        class: vendor\ext_name\path_to_class
        arguments:
             - '%core.root_path%'
For example listener file:

Code: Select all

	/** @var phpBB root path */
	protected $root_path;
	/**
	* Constructor
	*
	* @param string $root_path Path to the phpbb includes directory.
	*/
	public function __construct($root_path)
	{
		$this->root_path = $root_path;
	}
Usus est magister optimus! phpBB pre-Triton & latest php environment.
When answer lies in the question, question becomes redundant!
User avatar
Restless Rancor
Registered User
Posts: 196
Joined: Tue Sep 18, 2018 1:51 pm

Re: ACP expressions

Post by Restless Rancor »

GanstaZ wrote: Tue Sep 25, 2018 1:51 pm Board root is defined for example in index file:

Code: Select all

$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
And it can be used in any extension via injected (symfony container) parameter (service .yml file):

Code: Select all

services:
    serive_name:
        class: vendor\ext_name\path_to_class
        arguments:
             - '%core.root_path%'
For example listener file:

Code: Select all

	/** @var phpBB root path */
	protected $root_path;
	/**
	* Constructor
	*
	* @param string $root_path Path to the phpbb includes directory.
	*/
	public function __construct($root_path)
	{
		$this->root_path = $root_path;
	}
Hi, I've tried a few variations which were unsuccessful.
Is it possible that the ability to use %sitename% to display the site name was added by an extension and therefore there isn't an alternative %text% for the root path?

Edit: Sorry I could have answered this question a long time ago by testing it on a test board with no extensions. The answer is "yes", that function was added by an extension. I think I know which one, so I'll ask in the extension topic to see how easy it'd be to add one for %siteurl.

Thanks
These are not the droids you're looking for...
User avatar
GanstaZ
Registered User
Posts: 1187
Joined: Wed Oct 11, 2017 10:29 pm
Location: GZOverse

Re: ACP expressions

Post by GanstaZ »

Sitename is set as a global variable for templates (it can be used via $config serivce in php scripts like index.php): it is injected into template Here. Sitename can be called in php scripts as well => $config['sitename'] or in extensions when injected into a service like above method for root path.
Usus est magister optimus! phpBB pre-Triton & latest php environment.
When answer lies in the question, question becomes redundant!
User avatar
Restless Rancor
Registered User
Posts: 196
Joined: Tue Sep 18, 2018 1:51 pm

Re: ACP expressions

Post by Restless Rancor »

Thanks for the info, I'll take a look at that link to see if I can make the required changes myself.
It's just a nitpick to be honest, if I have to put the URL as text without using %siteurl% it's not the end of the world.

Thanks
These are not the droids you're looking for...
User avatar
GanstaZ
Registered User
Posts: 1187
Joined: Wed Oct 11, 2017 10:29 pm
Location: GZOverse

Re: ACP expressions

Post by GanstaZ »

Well.. it's hard to tell what you want to achieve. More info (specially piece of code) is needed)
Usus est magister optimus! phpBB pre-Triton & latest php environment.
When answer lies in the question, question becomes redundant!
User avatar
Restless Rancor
Registered User
Posts: 196
Joined: Tue Sep 18, 2018 1:51 pm

Re: ACP expressions

Post by Restless Rancor »

GanstaZ wrote: Tue Sep 25, 2018 2:19 pm Well.. it's hard to tell what you want to achieve. More info (specially piece of code) is needed)
I'm able to use %sitename% in text fields set in the ACP. I'm able to do this in forum descriptions, custom pages via the Official Pages Extension, Custom Registration Agreement extension and even in posts.
I'd like to be able to do the same with %siteurl% but instead of it displaying the site name, it displays the root path.

The main reason for this is if these change I wouldn't have to manually update them, as they'd automatically change.

Edit: Not sure about the code, but I suspect this extension added the ability to use %sitename% and have asked in that topic.

Thanks
These are not the droids you're looking for...
User avatar
GanstaZ
Registered User
Posts: 1187
Joined: Wed Oct 11, 2017 10:29 pm
Location: GZOverse

Re: ACP expressions

Post by GanstaZ »

This should point you to the right direction UCP register.
Usus est magister optimus! phpBB pre-Triton & latest php environment.
When answer lies in the question, question becomes redundant!
Post Reply

Return to “phpBB Custom Coding”