Advertisement:

Author Topic: Adding in a BBC box to my pages ..  (Read 5844 times)

Offline sangwe11

  • Full Member
  • ***
  • Posts: 680
  • The Pirate, Arrr!
    • sangwe11's Code Dump
Adding in a BBC box to my pages ..
« on: November 14, 2009, 12:05:43 PM »
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.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,795
    • StoryBB/StoryBB on GitHub
Re: Adding in a BBC box to my pages ..
« Reply #1 on: November 14, 2009, 12:21:24 PM »
You would be advised to start off looking at the code in Post.php, specifically the code concerning:

Code: [Select]
// 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);
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline sangwe11

  • Full Member
  • ***
  • Posts: 680
  • The Pirate, Arrr!
    • sangwe11's Code Dump
Re: Adding in a BBC box to my pages ..
« Reply #2 on: November 14, 2009, 12:29:28 PM »
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.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,795
    • StoryBB/StoryBB on GitHub
Re: Adding in a BBC box to my pages ..
« Reply #3 on: November 14, 2009, 12:43:31 PM »
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
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline sangwe11

  • Full Member
  • ***
  • Posts: 680
  • The Pirate, Arrr!
    • sangwe11's Code Dump
Re: Adding in a BBC box to my pages ..
« Reply #4 on: November 14, 2009, 12:47:41 PM »
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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,795
    • StoryBB/StoryBB on GitHub
Re: Adding in a BBC box to my pages ..
« Reply #5 on: November 14, 2009, 12:52:06 PM »
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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline sangwe11

  • Full Member
  • ***
  • Posts: 680
  • The Pirate, Arrr!
    • sangwe11's Code Dump
Re: Adding in a BBC box to my pages ..
« Reply #6 on: November 14, 2009, 12:56:19 PM »
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 ?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,795
    • StoryBB/StoryBB on GitHub
Re: Adding in a BBC box to my pages ..
« Reply #7 on: November 14, 2009, 12:58:05 PM »
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 :)
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline sangwe11

  • Full Member
  • ***
  • Posts: 680
  • The Pirate, Arrr!
    • sangwe11's Code Dump
Re: Adding in a BBC box to my pages ..
« Reply #8 on: November 14, 2009, 12:59:37 PM »
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 !!!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,795
    • StoryBB/StoryBB on GitHub
Re: Adding in a BBC box to my pages ..
« Reply #9 on: November 14, 2009, 01:00:52 PM »
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...
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline sangwe11

  • Full Member
  • ***
  • Posts: 680
  • The Pirate, Arrr!
    • sangwe11's Code Dump
Re: Adding in a BBC box to my pages ..
« Reply #10 on: November 14, 2009, 01:12:15 PM »
Success !!!

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

Still no show on the bbc though ..

I have this in my Source file ..

Code: [Select]
// 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 ..

Code: [Select]
<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 :/

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,795
    • StoryBB/StoryBB on GitHub
Re: Adding in a BBC box to my pages ..
« Reply #11 on: November 14, 2009, 01:44:32 PM »
So what exactly do you/don't you get?
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline sangwe11

  • Full Member
  • ***
  • Posts: 680
  • The Pirate, Arrr!
    • sangwe11's Code Dump
Re: Adding in a BBC box to my pages ..
« Reply #12 on: November 14, 2009, 01:49:47 PM »


The big box is what I get ..

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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,795
    • StoryBB/StoryBB on GitHub
Re: Adding in a BBC box to my pages ..
« Reply #13 on: November 14, 2009, 01:56:38 PM »
Ah, you mean the buttons... hmm. Not sure off hand how that's done.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline sangwe11

  • Full Member
  • ***
  • Posts: 680
  • The Pirate, Arrr!
    • sangwe11's Code Dump
Re: Adding in a BBC box to my pages ..
« Reply #14 on: November 14, 2009, 02:23:14 PM »
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.

Offline sangwe11

  • Full Member
  • ***
  • Posts: 680
  • The Pirate, Arrr!
    • sangwe11's Code Dump
Re: Adding in a BBC box to my pages ..
« Reply #15 on: November 14, 2009, 02:57:38 PM »
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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,795
    • StoryBB/StoryBB on GitHub
Re: Adding in a BBC box to my pages ..
« Reply #16 on: November 14, 2009, 03:01:39 PM »
All the BBcodes for the editor are declared in Subs-Editor.php. Smileys loaded too, I think.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline sangwe11

  • Full Member
  • ***
  • Posts: 680
  • The Pirate, Arrr!
    • sangwe11's Code Dump
Re: Adding in a BBC box to my pages ..
« Reply #17 on: November 14, 2009, 03:02:56 PM »
Ok, and the context variables for them are ?

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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,795
    • StoryBB/StoryBB on GitHub
Re: Adding in a BBC box to my pages ..
« Reply #18 on: November 14, 2009, 03:06:25 PM »
$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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline sangwe11

  • Full Member
  • ***
  • Posts: 680
  • The Pirate, Arrr!
    • sangwe11's Code Dump
Re: Adding in a BBC box to my pages ..
« Reply #19 on: November 14, 2009, 03:30:45 PM »
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