Entering the Sitename via bbCode

Get help developing custom BBCodes or request one.
Post Reply
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Entering the Sitename via bbCode

Post by david63 »

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!

I now no longer support any of my extensions but they will start to become available here
User avatar
kasimi
Former Team Member
Posts: 4900
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: Entering the Sitename via bbCode

Post by kasimi »

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: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Entering the Sitename via bbCode

Post by JoshyPHP »

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 library that handles markup in phpBB 3.2+.
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Entering the Sitename via bbCode

Post by david63 »

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!

I now no longer support any of my extensions but they will start to become available here
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Entering the Sitename via bbCode

Post by JoshyPHP »

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 library that handles markup in phpBB 3.2+.
User avatar
karbiko
Registered User
Posts: 97
Joined: Thu Jul 24, 2008 8:47 pm
Location: La Isla Bonita
Contact:

Re: Entering the Sitename via bbCode

Post by karbiko »

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”