I don't think I've outright asked this before. It's not like I beg for someone to contribute to my extensions all the time. Please give this request a chance and think about it. 🤞
I know developers do not like to do this because they either do not have time, do not want to do someone else's work, or they (you) want the person (me) to learn how to do these things themselves.
But, I spent 8 hours today trying to add a fof upload custom BBCode template to my Essential Audio extension. I looked at an extension Clark did which is similar and tried various combinations. Either there is something wrong with my local installation, or I am missing something.
I am able to add a custom template to the upload extension by manually adding this code to the forum's main extend.php
file:
<?php
use Flarum\Extend;
use Flarum\Foundation\AbstractServiceProvider;
use FoF\Upload\Contracts\Template;
use FoF\Upload\File;
use FoF\Upload\Helpers\Util;
class AudioTemplate implements Template
{
public function tag(): string
{
return 'audio';
}
public function name(): string
{
return 'Audio template';
}
public function description(): string
{
return 'Audio template to use with Essential Audio';
}
public function preview(File $file): string
{
return '[play]' . $file->url . '[/play]';
}
}
class AudioServiceProvider extends AbstractServiceProvider
{
public function register()
{
$this->container->make(Util::class)->addRenderTemplate($this->container->make(AudioTemplate::class));
}
}
return [
(new Extend\ServiceProvider())
->register(AudioServiceProvider::class),
];
However, if I instead try to do it like Clark's extension, I get boot errors. Flarum and the extension can't boot. The code can't find my provider class. Even though I have it in a src/Upload file just like Clark's extension. And yes, I updated namespaces and again, spent 8 hours on it... So, I tried. Hard.
And so, what I want to ask is: if anyone knows how to do this and could submit a pull request for my Essential Audio extension, I'd really, really appreciate it. I'm sure others will be grateful too because then Flarum would have an audio player which comes with a fof upload template. And, I'm betting there are people around here who could add the right code in about 10 minutes.
Plus, above is essentially the code with the correct BBCode template [play][/play]
for my Essential Audio extension. I'm just not putting things in the right spots probably. 😢 Or, my local environment is messed up.