Skip to main content
Topic: [WIP] Indent BBC (Read 2748 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[WIP] Indent BBC

[reserved]

Re: [WIP] Indent BBC

Reply #1

I am working on converting my SMF Indent BBC mod to ElkArte addon but  could not make it working. I am posting the code below.

From the subs file:
Code: [Select]
function IndentBBC(&$codes)
{
// Add bbc code(s)
$codes[] = array(
'tag' => 'indent',
'before' => '<div style="margin: 0 3%;">',
'after' => '</div>',
'block_level' => true
);
$codes[] = array(
'tag' => 'left-indent',
'before' => '<div style="margin-left: 3%;">',
'after' => '</div>',
'block_level' => true
);
$codes[] = array(
'tag' => 'right-indent',
'before' => '<div style="margin-right: 3%;">',
'after' => '</div>',
'block_level' => true
);
}

function IndentBBC_Buttons(&$bbc_tags)
{
global $txt, $context;

// Load language(s)
loadLanguage('IndentBBC');

// Add bbc button(s)
$context['bbc_tags'][] = array(
array(
'image' => 'IndentFullBBC',
'code' => 'indent',
'before' => '[indent]',
'after' => '[/indent]',
'description' => $txt['indent']
),
array(
'image' => 'IndentLeftBBC',
'code' => 'left-indent',
'before' => '[left-indent]',
'after' => '[/left-indent]',
'description' => $txt['left-indent']
),
array(
'image' => 'IndentRightBBC',
'code' => 'right-indent',
'before' => '[right-indent]',
'after' => '[/right-indent]',
'description' => $txt['right-indent']
),
);
}

From the hook file:
Code: [Select]
$hook_functions = array(
'integrate_bbc_codes' => 'IndentBBC|SOURCEDIR/addons/QRR.subs.php',
'integrate_bbc_buttons' => 'IndentBBC_Buttons|SOURCEDIR/addons/QRR.subs.php',
);

Full package is also attached. If anybody spotted any reason why it is not wokring, do post them here.

Re: [WIP] Indent BBC

Reply #2

At least the hooks seem to be wrong .. The File with the functions is named IndentBBC.subs.php but the hook is looking  for addon/QRR.subs.php

Quote$hook_functions = array(
   'integrate_bbc_codes' => 'IndentBBC|SOURCEDIR/addons/QRR.subs.php',
   'integrate_bbc_buttons' => 'IndentBBC_Buttons|SOURCEDIR/addons/QRR.subs.php',
);
Thorsten "TE" Eurich
------------------------

Re: [WIP] Indent BBC

Reply #3

Thank you @TE. Fixed that but the code is still not working. What is wrong this time. Hurmmm...  ::)

Package is attached for further analysis.

Re: [WIP] Indent BBC

Reply #4

You are going to find that adding buttons to the editor is a bit more involved with sceditor.  I'd suggest as a start to take a look at the move bbc addon that I put together, I think it will get you started with how to interface with the editor. http://addons.elkarte.net/bbc/BBC-Move.html

The hook you have to add the codes to parse_bbc look fine, its the hook to add buttons to the editor and then tell the editor what to do in both wizzy and source modes thats a bit more involved these days.
Last Edit: February 07, 2016, 02:37:08 pm by Spuds

Re: [WIP] Indent BBC

Reply #5

Thank you @Spuds. I will check and test that soon and update.

 

Re: [WIP] Indent BBC

Reply #6

Oh my god... I haven't this before? Lol...