News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Adding in a BBC box to my pages ..

Started by sangwe11, November 14, 2009, 12:05:43 PM

Previous topic - Next topic

sangwe11

I have two mods, not far from completion that need this.

Basically, I want to add whats shown below to my page creation page.



I understand I have to use a SMF function to generate the form ect, and not make my own, so I need to adjust my code accordingly, but what I am not getting is how on earth I get it to generate the form / bbc's ect ..

Any and all help is appreciated.

Arantor

You would be advised to start off looking at the code in Post.php, specifically the code concerning:

// Needed for the editor and message icons.
require_once($sourcedir . '/Subs-Editor.php');

// Now create the editor.
$editorOptions = array(
'id' => 'message',
'value' => $context['message'],
'labels' => array(
'post_button' => $context['submit_label'],
),
// We do XML preview here.
'preview_type' => 2,
);
create_control_richedit($editorOptions);

sangwe11

Mind explaining what each variable in the array does :D ?

I get the basic'ist of it, but I still can't get it to show.

Arantor

Do you get any errors? I haven't really used this myself though...

id -> the <div id> of the box
value -> the content the box should have
labels -> for the buttons that should be there
preview_type -> types of preview, I think 0 is for none, 2 for XML but I don't know about any others

sangwe11

Hmm now I'm confused haha  :o

I'm just taking a guess at these, so correct me if I'm wrong (if you know, seems this is the unknown lawl :D)

Also, are we talking this for each input box ? Or for all of them ?

id -> id of the div where I want it
value -> value to show (such as Page Name)
labels -> no idea on this
preview -> again, no idea

Arantor

Yeah, it's the div id where you want the form to be added. You'd specify that in the template.

value -> is the content the box has, for example for a post, it's blank on a new message, it has the existing message if you're editing, and has the quote if you're quoting someone.

labels -> for the buttons

preview -> depends if you a) want to have the inline preview like you normally get on posting, and b) want to have previewing anyway. Not so important if users can have WYSIWYG.

sangwe11

Ahh, 2 things I am stuck on, then I *should* be a go :D

the labels, is for the buttons right, so if I want to display the BBC buttons, what value do I have to specify ?

And is this for a single input ? or multiple ?

If it only adds a single, do I do my form like normal, and then just leave a blank div for it to put the bbc and message box in ?

Arantor

This is for a single postbox only.

The thing to do is to have a look at what the Post.template.php itself actually has in it. I have a feeling the create_ function sets it up for Post.template.php to display it, but it's something I've never gotten that far into, to be honest.

Perhaps I can come up with a mod where I find a need to create one :)

sangwe11

I can think of a few :D

I'll pm them you sometime xD

And i'll have a look and a mess around, and run back here screaming like a lil girl when it dont work haha !!!

Arantor

None of my current to-do list entries have any such need for it, to be honest.

Maybe when I get that lot cleared, though...

sangwe11

Success !!!

I've got it showing a box !! HAHA !

Still no show on the bbc though ..

I have this in my Source file ..

// Needed for the editor and message icons.
require_once($sourcedir . '/Subs-Editor.php');

// Now create the editor.
$editorOptions = array(
'id' => 'page_content_box',
'value' => '',
'labels' => array(
),
// We do XML preview here.
'preview_type' => 2,
);
create_control_richedit($editorOptions);


And this in my template file ..

<div id="page_content_box">', template_control_richedit('page_content_box', 'bbc') ,'</div>

I think its something to do with labels, but I'm not sure what I put in there :/

Arantor


sangwe11



The big box is what I get ..

I want the BBC's to be above it, like normal.

Arantor

Ah, you mean the buttons... hmm. Not sure off hand how that's done.

sangwe11

Ahh okk ..

I couldn't see anything different in the post / .template as to what I was doing, so I'm taking a look at the Enhanced Quick Reply (quick reply with bbc's basically) to see if I can gain any knowledge from that.

sangwe11

Well I have them there, but its not using any of the methods I was trying.

I basically used the code from the mod I was looking at (yes, i'll ask for permission before releasing, if I don't find another way, or rewrite it, which I probably will IMHO) to manually echo all the bbc's ..

All I need to know, is that is there a array in $context with all the bbc's and smileys stored in ? ATM i'm redefining them, but it wouldn't work for custom bbc's

Arantor

All the BBcodes for the editor are declared in Subs-Editor.php. Smileys loaded too, I think.

sangwe11

Ok, and the context variables for them are ?

$context['bbc'] and $context['smiley'] ?

Arantor

$context['bbc_tags'] for the first, but it's populated in Subs-Editor.php in the very function you should be calling.

$context['smileys'] for the second, but again is populated in Subs-Editor.php in create_control_richedit. It might be worth you looking through that function.

sangwe11

Well until someone finds a way on how to do it properly, I'm going to use my method.

It now gets the BBC array from the subs-editor, along with the smiley array, and looks like the original bbc editor, and works the same :D


Advertisement: