Advertisement:

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

Offline Marcus Forsberg

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,608
  • Gender: Male
    • marcus.t.forsberg on Facebook
    • marcusforsberg on LinkedIn
    • @marcusforsberg on Twitter
    • marcusforsberg.net
Re: Adding in a BBC box to my pages ..
« Reply #20 on: November 14, 2009, 03:39:13 PM »
Code: [Select]
<div id="page_content_box">', template_control_richedit('page_content_box', 'bbc') ,'</div>

What happens if you use this:

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

Offline sangwe11

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

was I suppose to be adding divs for them too ?

haha !

that might be why it wouldn't work !!

Offline sangwe11

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

Offline Marcus Forsberg

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,608
  • Gender: Male
    • marcus.t.forsberg on Facebook
    • marcusforsberg on LinkedIn
    • @marcusforsberg on Twitter
    • marcusforsberg.net
Re: Adding in a BBC box to my pages ..
« Reply #23 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.

Offline sangwe11

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

Offline Marcus Forsberg

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,608
  • Gender: Male
    • marcus.t.forsberg on Facebook
    • marcusforsberg on LinkedIn
    • @marcusforsberg on Twitter
    • marcusforsberg.net
Re: Adding in a BBC box to my pages ..
« Reply #25 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

Offline sangwe11

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

Offline Marcus Forsberg

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,608
  • Gender: Male
    • marcus.t.forsberg on Facebook
    • marcusforsberg on LinkedIn
    • @marcusforsberg on Twitter
    • marcusforsberg.net
Re: Adding in a BBC box to my pages ..
« Reply #27 on: November 15, 2009, 09:50:34 AM »
I figured the basics out, but not the preview function. Plus, it doesn't do a thing when you hit "Submit" :P

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(
'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:

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

Offline Marcus Forsberg

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,608
  • Gender: Male
    • marcus.t.forsberg on Facebook
    • marcusforsberg on LinkedIn
    • @marcusforsberg on Twitter
    • marcusforsberg.net
Re: Adding in a BBC box to my pages ..
« Reply #28 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

Offline sangwe11

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

Offline Marcus Forsberg

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,608
  • Gender: Male
    • marcus.t.forsberg on Facebook
    • marcusforsberg on LinkedIn
    • @marcusforsberg on Twitter
    • marcusforsberg.net
Re: Adding in a BBC box to my pages ..
« Reply #30 on: November 15, 2009, 10:00:25 AM »
Yes, works fine for me. Try the code ;)

Offline sangwe11

  • Full Member
  • ***
  • Posts: 680
  • The Pirate, Arrr!
    • sangwe11's Code Dump
Re: Adding in a BBC box to my pages ..
« Reply #31 on: November 15, 2009, 10:01:49 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 ?

Offline Marcus Forsberg

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,608
  • Gender: Male
    • marcus.t.forsberg on Facebook
    • marcusforsberg on LinkedIn
    • @marcusforsberg on Twitter
    • marcusforsberg.net
Re: Adding in a BBC box to my pages ..
« Reply #32 on: November 15, 2009, 10:03:01 AM »
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.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,782
    • StoryBB/StoryBB on GitHub
Re: Adding in a BBC box to my pages ..
« Reply #33 on: November 15, 2009, 10:03:18 AM »
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.
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 #34 on: November 15, 2009, 12:08:15 PM »
Any luck with the preview yet ?

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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,782
    • StoryBB/StoryBB on GitHub
Re: Adding in a BBC box to my pages ..
« Reply #35 on: November 15, 2009, 12:22:01 PM »
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...
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 #36 on: November 15, 2009, 12:49:35 PM »
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 >.<
« Last Edit: November 15, 2009, 01:03:07 PM by sangwe11 »