News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Adding in a BBC box to my pages ..

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

Previous topic - Next topic

Marcus Forsberg

Quote from: sangwe11 on November 14, 2009, 01:12:15 PM
<div id="page_content_box">', template_control_richedit('page_content_box', 'bbc') ,'</div>

What happens if you use this:

<div id="page_content_box">', template_control_richedit_buttons('page_content_box', 'smileyBox_message', 'bbcBox_message');</div>

Then add a div with id "smileyBox_message" and one with id "bbcBox_message". Should display smileys and BBCs properly, if I understood it right.

sangwe11

ohhh !

was I suppose to be adding divs for them too ?

haha !

that might be why it wouldn't work !!

sangwe11

hmm, now all I get is the submit and preview boxes .. now message, bbc or smiley box.

edit:

fixed by removing the _buttons part at the end ..

now to add in the buttons again, as removing the _buttons removes the buttons lawl.

also, none of the buttons actually do anything, they just show.

Marcus Forsberg

Oh well, it was quite a while ago I worked on this. Will look at it when time allows and get back here.

sangwe11

Quote from: Nas on November 14, 2009, 03:55:24 PM
Oh well, it was quite a while ago I worked on this. Will look at it when time allows and get back here.

Which mod was it ?

I *could* (with permission :D) look through the source code, and see how you did it.

Marcus Forsberg

Actually, it wasn't a mod. I just looked at it without ever doing anything with it, for whatever reason. :P

sangwe11

Quote from: Nas on November 14, 2009, 03:59:30 PM
Actually, it wasn't a mod. I just looked at it without ever doing anything with it, for whatever reason. :P

Oh ok ...

Well I do have a working version, so I'll go with that for now (will keep the code you suggested that almost works in a separate file for later use)

And if / when I or you figure out whats missing, I'll swap the code over, seeing as the proper way is under 1/8 of the size of the "hackish" way.

Marcus Forsberg

I figured the basics out, but not the preview function. Plus, it doesn't do a thing when you hit "Submit" :P

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(
'post_button' => 'Save/Submit/Whatever/',
),
// We do XML preview here.
'preview_type' => 2,
);
create_control_richedit($editorOptions);

// Store the ID.
$context['post_box_name'] = $editorOptions['id'];


Template file:

echo'<div id="bbcBox_message"></div>';
echo'<div id="smileyBox_message"></div>';

echo template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');

echo'
<span class="smalltext"><br />', $context['browser']['is_firefox'] ? $txt['shortcuts_firefox'] : $txt['shortcuts'], '</span><br />
', template_control_richedit_buttons($context['post_box_name']);


I'll be back.

Marcus Forsberg

Oh, stupid me. You don't have to do anything special to make it post, except adding a <form> tag with action="bla" .. :P
* Nas slaps self

sangwe11

Quote from: Nas on November 15, 2009, 09:56:52 AM
Oh, stupid me. You don't have to do anything special to make it post, except adding a <form> tag with action="bla" .. :P
* Nas slaps self

Rofl !!! :D

Generally helps.

Btw, are the bbc buttons working ?

I got them to show before, but they didn't do anything when clicked.

Marcus Forsberg


sangwe11

Quote from: Nas on November 15, 2009, 10:00:25 AM
Yes, works fine for me. Try the code ;)

Will do :D

And as for the preview, do we have to add another function or something ?

Marcus Forsberg

Not sure how it works. Looking at it now.
You might want to look at Post.php and Post.template.php yourself too, to see if you find it.

Arantor

Might need to make sure $settings['default_theme_url'] . '/scripts/editor.js' is loaded.


EDIT: Or not.

To make the preview work you need to add a bunch more stuff, like a new subaction, ensure that it spits out XML... basically, see what the post action and preview does.

sangwe11

Any luck with the preview yet ?

I haven't had a chance to look, been busy with expressions and making my parsing function simpler.

Arantor

See above: it's not just a simple thing. You need to have an action or subaction whose job it is to make the preview and output it via XML, plus some JS to actually send the data to the action/subaction in the first place, then some more JS to display it.

In short, what the post code does...

sangwe11

#36
Just tried your code Nas, and couldn't get it to display any BBC buttons.

Not sure what I've done wrong, I'll try to figure it out.

Nevermind .. silly mistake. . was require_once'ing the file twice >.<

Advertisement: