Entering the Sitename via bbCode

Get help developing custom BBCodes or request one.
Post Reply
User avatar
david63
Jr. Extension Validator
Posts: 14644
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Entering the Sitename via bbCode

Post by david63 » Sun Apr 01, 2018 1:25 pm

I admit that I know next to nothing about creating bbCodes as it is an area I have never really had a need to delve into.

For an extension that I am working on it would be useful to have a bbCode (probably via a listener event) to be able to add the site name from the config db table.

Is this possible? If so could I have some clues as to how to go about it please.
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
kasimi
Extension Customisations
Extension Customisations
Posts: 3097
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: Entering the Sitename via bbCode

Post by kasimi » Sun Apr 01, 2018 2:36 pm

Maybe this and this is what you want? You can access the $configurator object in the core.text_formatter_s9e_configure_after event.

User avatar
JoshyPHP
Code Contributor
Posts: 949
Joined: Mon Jul 11, 2011 12:28 am

Re: Entering the Sitename via bbCode

Post by JoshyPHP » Sun Apr 01, 2018 7:42 pm

You can use a template parameter in your BBCode template and set its value via core.text_formatter_s9e_renderer_setup. The most reliable way to use a parameter in a template would be this:

Code: Select all

<xsl:value-of select="$MY_PARAM"/>
Technically you can also use {MY_PARAM} anywhere in the text as long as it doesn't collide with the name of a token like {TEXT} or {L_WHATEVER}.

https://area51.phpbb.com/docs/dev/3.2.x ... parameters
I wrote the thing that does BBCodes in 3.2.

User avatar
david63
Jr. Extension Validator
Posts: 14644
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Entering the Sitename via bbCode

Post by david63 » Tue Apr 17, 2018 9:54 am

OK - I hate to admit it but after over a week of trying to get this working I have given up.

I have worked through most of the examples with varying degrees of success so if somebody could point me in the direction of a working example of this, or something similar, I will be eternally grateful.

As I said at the outset I have never delved into BBCodes so the whole process is alien, well at least to me it is.
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
JoshyPHP
Code Contributor
Posts: 949
Joined: Mon Jul 11, 2011 12:28 am

Re: Entering the Sitename via bbCode

Post by JoshyPHP » Tue Apr 17, 2018 3:55 pm

Create a BBCode with {MY_PARAM} or <xsl:value-of select="$MY_PARAM"/> in its template then use an extension to set its value at rendering time.

Code: Select all

class listener implements EventSubscriberInterface
{
	public static function getSubscribedEvents()
	{
		return ['core.text_formatter_s9e_renderer_setup' => 'onRendererSetup'];
	}
	public function onRendererSetup($event)
	{
		$event['renderer']->get_renderer()->setParameter('MY_PARAM', 'My param');
	}
}
For the site's name, that'd be the same thing except your listener will need to access the database or something I guess.
I wrote the thing that does BBCodes in 3.2.

User avatar
karbiko
Registered User
Posts: 74
Joined: Thu Jul 24, 2008 8:47 pm
Location: La Palma, Canary Islands, Spain

Re: Entering the Sitename via bbCode

Post by karbiko » Mon May 21, 2018 9:06 pm

I'm not sure if this could be what you're looking for..

This ext phpBB You Me We Us Filter Extension let's you an special use for those 4 words into brackets

Anywhere you write [us], you will have the site name from db

And there will be a change by using the other 3 words in brackets..

was this what you need?

Post Reply

Return to “Custom BBCode Development and Requests”

Who is online

Users browsing this forum: No registered users and 9 guests