Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: gbsothere on September 21, 2009, 08:32:32 PM

Title: BBC Options for News?
Post by: gbsothere on September 21, 2009, 08:32:32 PM
How hard would it be to create a mod that provides BBC buttons (such as the Signature Dropdown Choice mod) for font colors, URLs, etc., (just some basic options) to be used in the News entry area? 


Title: Re: BBC Options for News?
Post by: Arantor on September 21, 2009, 08:34:41 PM
I'm not sure what its potential for BBC actually is; I seem to recall having to use raw HTML in the past to do some things concerning links.
Title: Re: BBC Options for News?
Post by: gbsothere on September 21, 2009, 08:39:38 PM
We use BBC to enter things like colors and logos, etc:

(http://whereitestmystuff.com/images/newssample.jpg)


I suppose we could also use HTML.  There's a lot of "copying" an existing entry and just changing the image URL or the color, to keep from having to enter the codes again.

Title: Re: BBC Options for News?
Post by: Arantor on September 21, 2009, 08:44:18 PM
Hmm, I didn't realise how fully supported it was.

Adding a fuller set of entry boxes shouldn't be *that* hard, just the JS is a little complex to ensure it's always pointing to the right box for you.
Title: Re: BBC Options for News?
Post by: gbsothere on September 21, 2009, 08:46:55 PM
It will even support animated gifs, although that's a bit unnecessary with the fader.   :)

Our posters keep up with a lot of recurring shows, sports announcements; that sort of things and so we try to flavor the entries a bit with network logos and enough color to keep it interesting. 



A friend of mine uses his news flasher as an "ad" displayer, although I personally wouldn't want to muck about with TOS.
Title: Re: BBC Options for News?
Post by: Arantor on September 21, 2009, 08:56:22 PM
Well, an image is an image; neither <img> or the BBcode equivalent know or care to be honest.

I would wonder if it's not worth going for something more specific to your site; even if this mod is implemented as you're suggesting, you're still going to be doing a lot manually.
Title: Re: BBC Options for News?
Post by: gbsothere on September 21, 2009, 09:02:48 PM
Well, that's true; I feel I spend as much time rotating News, due to ever-changing schedules, etc., as I do tending to any other facet of the forum.  I guess this is probably more a "luxury" mod than a utility mod, since not everyone uses their news flasher to the same extent or even with the same amount of embellishment.  It does get the posters' attention, though, as opposed to plain black font.  They get so used to seeing that out of their peripheral that they forget to notice.
Title: Re: BBC Options for News?
Post by: Arantor on September 21, 2009, 09:12:04 PM
I was thinking maybe a few custom BBcodes might suit you a little better is all.

If it supports BBcode, which I'm quite likely wrong about - I don't use the news much - a few custom BBcodes might suit you a lot better in terms of effort.

For example, [logo]fox[/logo] perhaps? Pretty much whatever you'd want can be made.
Title: Re: BBC Options for News?
Post by: gbsothere on September 21, 2009, 09:17:12 PM
That actually sounds perfect!  I do use all BBC code for images, urls, colors, italics, etc.  Just some basic buttons, I think, would be all that's needed.  I don't know if pull-downs would come into play for things like font and color choices but I won't deny that it would be nice. 

Title: Re: BBC Options for News?
Post by: Arantor on September 21, 2009, 09:19:46 PM
I wasn't going into the buttons aspect - I was going into the realms of setting up custom BBcode first. I'm not sure how much benefit you'd get from custom BBcode + custom buttons though.
Title: Re: BBC Options for News?
Post by: gbsothere on September 21, 2009, 09:33:53 PM
I suppose I was hoping that just above the top frame (where it says Preview) there might be BBC buttons that interacted with whichever box one happened to be typing in, but I can also see where that might be unrealistic.  I'm not sure how custom BBcode would work without the buttons to activate it but I'm not very knowledgeable about these kinds of things.  Being not much more than a host trying to run a nice forum, I have to rely on the expertise of mod authors. :)

Anything that would keep me from having to manually type out the code for every entry would be a big help.

(http://whereitestmystuff.com/images/news2.jpg)
Title: Re: BBC Options for News?
Post by: Arantor on September 22, 2009, 07:03:18 AM
Well... first up, [red] is a bbcode tag, as is [green] (the red tag is auto replaced internally with its color equivalent)

I'm also wondering about a date tag for your Wednesday... bit, e.g. [date]9/23/09[/date].

It would be easier to have the custom tags in place first before attempting buttons.
Title: Re: BBC Options for News?
Post by: gbsothere on September 22, 2009, 08:28:31 AM
I didn't realize that; that each color, for instance, was its own BBcode.  I guess I thought it would be similar to the way Post.template.php and Post.english.php reference each other using the strings found in Modification.english.php but there's not exactly a News.template.php and News.english.php.  (It's probably not a good idea for SMF to just let dumb forum owners roam around freely in here.)  :D

We use Kays' Signature Dropdown Choice mod in our profile's signatures and I suppose I thought that it might be the same sort of thing; just some basic embellishment but in the News area.  I don't mind manually typing in things like the date when I'm entering the event, but if a BBcode made that even easier, of course it would be welcome.  The things that we find ourselves having to enter with every News entry are URL, Image URL, Color, Font and an occasional set of italics.  (Pretty much just those, but the News is changed so frequently, it becomes tedious.)  I can achieve that, now, by manually typing in the code, but if there were something "clickable" that would render the tags, that would be much appreciated.

Really, Arantor, whatever you feel is the best way to achieve it; I'd be very grateful.  It's apparent that I don't know enough about this to grasp what you're telling me, but I know that you do.  I know I'd be happy with the results.
Title: Re: BBC Options for News?
Post by: Arantor on September 22, 2009, 09:07:27 AM
No, News is handled very much on its own, by one of the admin pages IIRC (never looked in huge detail on it)

I guess it comes back to what you have. Do you have a stock set of images to work from, for example?
Title: Re: BBC Options for News?
Post by: gbsothere on September 22, 2009, 09:23:25 AM
No, I don't really have a stock set of images, although I find that I do use many of the same ones frequently, depending on what we're announcing.  I find something on the Internet that might do well for embellishing the announcement (such as a birthday cake for a special member recognition or the logo of a particular network or sports team) and I resize it and send it up to my server to link to.  I try to keep them all the same uniform size because, although many may not be aware of this, if one news announcement takes up more lines than another (requiring more height for that announcement) then the news field will constantly resize up and down with each flash to accommodate the height.  This causes "page jumps".  I know there is an IE bug that also causes page jumps but another cause of this is when items in the News field differ in content size, creating different different heights. 

*laughing*   All that to say, "No, I don't really have a stock set, but I do use a uniform size".
Title: Re: BBC Options for News?
Post by: Arantor on September 22, 2009, 09:26:53 AM
Well, the most frequently could be turned straight into tags (or, thinking about it, smileys - just hidden from the post form), e.g. :fox: for the FOX logo - there's even a handy interface for that already, and I'm not sure it's something you'll really be able to make into a useful button if it's not a particularly stock set.
Title: Re: BBC Options for News?
Post by: gbsothere on September 22, 2009, 09:31:19 AM
That's a thought, creating hidden smileys and posting the tooltips (keeping them simple enough to recall them easily).  I suppose I could create a new smiley set composed of just that sort of thing and make them all hidden?
Title: Re: BBC Options for News?
Post by: Arantor on September 22, 2009, 09:44:04 AM
I think you'd have to extend the standard set since it'll use whatever your users have as default.
Title: Re: BBC Options for News?
Post by: gbsothere on September 22, 2009, 10:08:26 AM
That's right; I hadn't thought of that. The whole point is for them be able to see it.   :D
I just tested this on my test site and using the tooltip code for a hidden "smiley" in the Newsflasher does work well.  I just have to remember to make every entry uniform in content size to keep the page from jumping.

:)
Title: Re: BBC Options for News?
Post by: gbsothere on September 22, 2009, 09:37:07 PM
I managed to get the BBC buttons and pulldowns to show up on ManageNews.template.php.  I just can't get them to actually interact with the input box.  (They're not "clickable".)  The pulldowns reveal all the expected font face/color/size choices.  But there doesn't seem to be any relationship between them and the input box.  They're "disabled tags", I guess.   ::)

But, hey, I "dabbled"...   even if it doesn't work, it's a nice fake.   :D

(http://whereitestmystuff.com/images/newstemplate.jpg)
Title: Re: BBC Options for News?
Post by: Arantor on September 22, 2009, 09:56:59 PM
Good start :)

The reason they're disabled is because you're missing the Javascript that gets included too. The problem with said JS is that it's geared to a given textbox with a given name - and on the news page you can have multiple entries.
Title: Re: BBC Options for News?
Post by: gbsothere on September 22, 2009, 10:01:13 PM
This is literally me, right now--------->  (http://whereikeepmystuff.com/smf/Smileys/classic/scratchhd.gif)




I don't suppose you'd want to take a look at my ManageNews.template.php file would you? 

I brought my sign...

(http://whereitestmystuff.com/images/help.gif)


:D
Title: Re: BBC Options for News?
Post by: Arantor on September 22, 2009, 10:04:29 PM
I wouldn't know where to start to be honest; I know it's driven from editor.js but I don't know any more than that to be honest.
Title: Re: BBC Options for News?
Post by: gbsothere on September 22, 2009, 10:07:00 PM
Do you think we should move this to Coding Discussion to see if anyone knows how to plug this thing in and make it run?   :)
Title: Re: BBC Options for News?
Post by: Arantor on September 22, 2009, 10:27:43 PM
Sounds like a plan.
Title: Re: BBC Options for News?
Post by: gbsothere on September 22, 2009, 10:38:31 PM
Thanks, Arantor!   :)


If any coder who wanders by feels like helping an old man out...   

Would you take a look at the attached ManageNews.template.php (this one is for 1.1.10) and help me figure out how to make these BBC buttons and pulldowns over the News input box interact with it?  (I realize that the option "Click here to add another item" produces yet another input box, so that might complicate things.)  Right now, although the pulldowns reveal the proper font faces/color/size, these are all disabled.   :(


(http://whereitestmystuff.com/images/newstemplate.jpg)


We use our news fader quite a bit and incorporate things like images, colors, URLs, etc.


(http://whereitestmystuff.com/images/newssample.jpg)


Right now, we have to manually type in BBcode for everything.


(http://whereitestmystuff.com/images/news2.jpg)


  This is why I'm hoping to make these buttons active. 

Any help would be much appreciated.   :)


Title: Re: BBC Options for News?
Post by: SAFAD on September 23, 2009, 06:13:10 PM
Yea
The Signature are bbcode may help you
Arnator Go For IT x)
Title: Re: BBC Options for News?
Post by: gbsothere on September 23, 2009, 06:42:08 PM
I can't get the javascript to "marry" the BBCode buttons and the text input area.

I think it's because, as Arantor pointed out earlier, the News input area is different from, say, a regular post box, because it has the option "Click here to add another item", which renders yet another input box. 

I was looking at the page source of the News area and saved that as an index.php file (attached below).  This bit of code from it references the input box:

<tr class="windowbg2">
<td align="center">
<div id="moreNewsItems"></div><div id="moreNewsItems_link" style="display: none;"><a href="javascript:void(0);" onclick="addNewsItem(); return false;">Click here to add another item.</a></div>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
document.getElementById("moreNewsItems_link").style.display = "";

function addNewsItem()
{
setOuterHTML(document.getElementById("moreNewsItems"), '<div style="margin-bottom: 2ex;"><textarea rows="3" cols="65" name="news[]" style="width: 85%;"></textarea></div><div id="moreNewsItems"></div>');
}
// ]]></script>
<noscript>
<div style="margin-bottom: 2ex;"><textarea rows="3" cols="65" style="width: 85%;" name="news[]"></textarea></div>
</noscript>
</td>
<td colspan="2" valign="bottom" align="right" style="padding: 1ex;">
<input type="submit" name="save_items" value="Save" /> <input type="submit" name="delete_selection" value="Remove selected" onclick="return confirm('Are you sure you want to delete the selected news items?');" />
</td>
</tr>
</table>
<input type="hidden" name="sc" value="85ea2ae92e4c87b22f54afae7a000ec4" />
</form>
</td>
</tr>
</table>


I wondered if either the tr class or the div id could somehow be referenced in the javascript to create a relationship between the BBCode buttons and the text areas.

:-\
Title: Re: BBC Options for News?
Post by: Arantor on September 23, 2009, 09:50:12 PM
OK, let me explain how it works - and why on a second glance it might not be so bad if I can dredge up the knowledge of how to do it.

When you have an HTML form you have to supply names for each element. But since you can't have multiple elements the same name, you're a bit stuck. Thus there is the array variant.

As you can see from that source, news boxes are <textarea> with names of 'news[]'. This means the first one is news[0], the second news[1] and so on.

If you were to trigger an event on selecting the box to say 'the current one is box n', then have the Javascript directed there, it becomes possible - but it's a clone of the editor.js file with tweaks.
Title: Re: BBC Options for News?
Post by: gbsothere on September 23, 2009, 10:00:35 PM
Would setting a limit (albeit, a generous one) on the number of allowed news entries make it any less complicated, rather than the implied "infinite" number allowed?   Or is that really not an issue? 


Title: Re: BBC Options for News?
Post by: Arantor on September 23, 2009, 10:01:23 PM
Would make no different to the code at any practical level.

There are limits - several of them - but you're never liable to actually hit any of them.
Title: Re: BBC Options for News?
Post by: gbsothere on September 23, 2009, 10:09:57 PM
*heavy sigh*

This stuff seems like rocket science. 



Thank you for explaining it, Arantor.  I'll light my pipe and mull it over and hope for comprehension to dawn. 

:)

Title: Re: BBC Options for News?
Post by: Arantor on September 24, 2009, 03:21:54 AM
I love it when people compare things to rocket science; having actually built rockets in a science class (which was actually entitled, "So you think you're a rocket scientist?"), I can say that programming in PHP is actually easier.

Just to clarify on the limits:
I don't think there is an implicit limit on the number of items you can have referenced with news[]. If there is, it'll likely be in the order of 32767. Your mileage will vary depending on browser.

There is, however, a direct limit on news items.

For those who don't know the mechanics, all of the news articles are actually chunked together into a single row in the smf_settings table. Line breaks in the entries themselves are converted to <br />, then it's stored as one 'line' per news entry in the database.

The limit is that there is a total of 65534 characters available for this field.
Title: Re: BBC Options for News?
Post by: gbsothere on September 24, 2009, 07:56:06 AM
With regard to rocket science and PHP, here's what an odd fellow I am:  I know absolutely nothing about rockets and the only reason I stumbled onto this web site is simply that I'm an old retired guy who's trying to host a little forum.  And yet, without exaggeration, I can tell you that I leave the television tuned to the NASA Channel all day long and have never missed a shuttle launch/landing/docking, space walk....   and while all this is going on in the background, I sit and stare at the SMF files as if I'll "crack the code" if I don't blink.   *grin*  I know nothing about either and yet I'm equally fascinated by both. 

:D

Title: Re: BBC Options for News?
Post by: SAFAD on September 24, 2009, 08:02:02 AM
@gb i didn't understand anything but i  like comparation with rocket sience to just like i feeel i can build a rocket :)
i have few things to do
so you have to wait me a little then i start working on it
regards
Title: Re: BBC Options for News?
Post by: Arantor on September 24, 2009, 08:36:29 AM
The problem with SMF code is that if you're not experienced at PHP, it feels like a wall of code.

Even when you are experienced, until you can start chipping away at it it's *still* a wall of code, but that's true for any sufficiently large machine.
Title: Re: BBC Options for News?
Post by: gbsothere on September 24, 2009, 08:41:02 AM
This, alone, justifies the existence of a test forum....   or several of them.   :)
Title: Re: BBC Options for News?
Post by: Arantor on September 24, 2009, 08:43:34 AM
I currently have four on my local PC :) though in varying stages of breakage...
Title: Re: BBC Options for News?
Post by: gbsothere on September 24, 2009, 08:48:04 AM
Quote from: Arantor on September 24, 2009, 08:43:34 AM
I currently have four on my local PC :) though in varying stages of breakage...


I'll try to look at it as Beta-Testing:   "Try to break it." 

Off I go, to give it the old college try.   :D
Title: Re: BBC Options for News?
Post by: Arantor on September 24, 2009, 09:19:37 AM
Oh, I'm very good at breaking it; I probably get a whitescreen error on 1 in 3 mods I write because I've missed something.

I think this is getting a little offtopic though.

Please feel free to play with it and I'll see if I can dig something out of this (my JS is not as hot as the SMF dev teams')
Title: Re: BBC Options for News?
Post by: gbsothere on September 24, 2009, 08:06:55 PM
Just a note...   getting closer.   :D

Cue Joe Cocker:  "A Little Help From My Friends".

I'll check back in when it's running smoothly. 


Title: Re: BBC Options for News?
Post by: Arantor on September 24, 2009, 08:09:38 PM
Are you going to make a mod out of this when you're done? It sounds like I might have some competition on my hands...
Title: Re: BBC Options for News?
Post by: gbsothere on September 24, 2009, 08:16:54 PM
Quote from: Arantor on September 24, 2009, 08:09:38 PM
Are you going to make a mod out of this when you're done? It sounds like I might have some competition on my hands...


Oh, no, not me.    :D    I really am just an old man who's trying to run a forum.  I'll leave the mods up to you guys.

But, when all the ducks are in a row, if you guys want to split the post with the final info in it off into Tips And Tricks, maybe someone else will want to use it.   :)

Title: Re: BBC Options for News?
Post by: Arantor on September 24, 2009, 08:17:43 PM
Well, if it's just a case of packaging I can arrange that for you (with your permission, of course) But let's get it working first :)
Title: Re: BBC Options for News?
Post by: gbsothere on September 24, 2009, 08:22:59 PM
Quote from: Arantor on September 24, 2009, 08:17:43 PM
Well, if it's just a case of packaging I can arrange that for you (with your permission, of course) But let's get it working first :)


I have a friend who's been helping me with it today.  He's already working on a project of his own, but I'll ask if he's interested in presenting it as a mod.  If not, one of you mod authors please take it.  If it has my name on it, I'll have to mind the support thread.   :o

And we don't want that.   :D

Title: Re: BBC Options for News?
Post by: Arantor on September 24, 2009, 08:29:35 PM
Pretty soon I'll have more mods that I am years old... but we'll see about it nearer the time.
Title: Re: BBC Options for News?
Post by: gbsothere on September 25, 2009, 12:11:11 PM
Got it working for 2.x.  I'll post the code here in a bit; I'm just messing around with 1.1.0 to see why it's not working there....

:-\
Title: Re: BBC Options for News?
Post by: Arantor on September 25, 2009, 02:28:25 PM
1.1 is a bit different in how it's built, but should be doable shortly enough. Let me know if there's anything I can do to help.
Title: Re: BBC Options for News?
Post by: gbsothere on September 25, 2009, 04:57:12 PM
It's working for both, just a slight glitch in 1.1.10 to sort out.   :)

Are you going to want me to attach the files and/or post the coding here, or should I PM you that, so that you can check it out first?

Title: Re: BBC Options for News?
Post by: Arantor on September 25, 2009, 05:50:58 PM
Please feel free to post it here - either myself or someone else can then package it. That said, I'd prefer whoever did package it also understood how it worked as there will invariably be questions from other users.
Title: Re: BBC Options for News?
Post by: gbsothere on September 25, 2009, 10:15:52 PM
First, let me address this, because it will become an issue if more people begin to embellish their News entry areas.  The News Fader, for as long as I've been using SMF, both 1.x and 2.x versions, has been notorious for constantly "resizing" if the text in one entry isn't the same number of lines as the text in another entry  When this happens, the News Fader field contracts and expands with each different-sized entry.  This causes page jumps.


Here is the fix for 1.1.10 (what it does is give a "fixed size" to the news entry field that you can customize to your own needs):

http://www.simplemachines.org/community/index.php?topic=308953.msg2049731#msg2049731 (http://www.simplemachines.org/community/index.php?topic=308953.msg2049731#msg2049731)


Here is the fix for RC1.2 (Boardindex.template.php):

Find:

smfNewsFadeToggle.addToggleImage("newsupshrink", "/collapse.gif", "/expand.gif");
      smfNewsFadeToggle.addTogglePanel("smfNewsFader");
   // ]]></script>
   <div class="tborder marginbottom">


Replace with:

smfNewsFadeToggle.addToggleImage("newsupshrink", "/collapse.gif", "/expand.gif");
      smfNewsFadeToggle.addTogglePanel("smfNewsFader");
   // ]]></script>
   <div class="tborder marginbottom" style="min-height:130px">



It's just an edit to the last line and, again, you can customize it.  (Thanks, jeza!)



Now..... as far as the News Drop down feature.  First, thank you so much, Arantor and thank you Kays for very patient, very wise advice.  And thank you, jeza (of SMF Arcade fame) for working out all the kinks and forcing Javascript into submission.
   :)


(http://whereitestmystuff.com/images/newstemplate2.jpg)


I will attach the two ManageNews.template.php files to this post (the first one being for 2.0 and the second one for 1.1.0 but here are the codes.  (They're working for me, and I hope they do for you.  I apologize for any weird white space that might make it difficult for you to find the string, at first.  I'm really no good at this.)

RC1.2 ManageNews.template.php

Find:

// Form for editing current news on the site.
function template_edit_news()
{
global $context, $settings, $options, $scripturl, $txt;

echo '


Add After:

<script language="JavaScript">
var box = "document.forms.postmodify.box1";
</script>
<script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/scripts/editor.js"></script>';

echo '

<script language="javascript">
function getElements(x)
  {
box = 'document.forms.postmodify.box'   x;
  }
</script>


Find:

// Loop through all the current news items so you can edit/remove them.

Add Before:

echo '
<tr class="windowbg2">
<td colspan="3">';










// Start News Dropdown mod
loadLanguage('Post');
echo '
<script language="JavaScript" type="text/javascript"><!-- // --><!','[CDATA[
function bbc_highlight(something, mode)
{
something.style.backgroundImage = "url("   smf_images_url   (mode ? "/bbc/bbc_hoverbg.gif)" : "/bbc/bbc_bg.gif)");
}
// ]]', '></script>';

$context['bbc_tags'] = array(
'img' => array('code' => 'img', 'before' => '[img]', 'after' => '[/img]', 'description' => $txt['image']),
            'url' => array('code' => 'url', 'before' => '[url]', 'after' => '[/url]', 'description' => $txt['bbc_url']),
);

foreach ($context['bbc_tags'] as $image => $tag) {
echo '
<a href="javascript:void(0);" onclick="surroundText('', $tag['before'], '', '', $tag['after'], '', eval(box)); return false;">'.
'<img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="', $settings['images_url'], '/bbc/', $image, '.gif" align="bottom" width="23" height="22" alt="', $tag['description'], '" title="', $tag['description'], '" style="background-image: url(', $settings['images_url'], '/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>';
}

// Begin font dropdown
echo '
<select onchange="surroundText('[font='   this.options[this.selectedIndex].value.toLowerCase()   ']', '[/font]', eval(box)); this.selectedIndex = 0; eval(box).focus(eval(box).caretPos);" style="margin-bottom: 1ex;">
<option value="" selected="selected">', $txt['font_face'], '</option>
<option value="courier">Courier</option>
<option value="arial">Arial</option>
<option value="arial black">Arial Black</option>
<option value="impact">Impact</option>
<option value="times new roman">Times New Roman</option>
<option value="georgia">Georgia</option>
<option value="andale mono">Andale Nono</option>
<option value="trebuchet ms">Trebuchet MS</option>
<option value="comic ms">Comic MS</option>
</select>';




echo '
<select onchange="surroundText('[color='   this.options[this.selectedIndex].value.toLowerCase()   ']', '[/color]', eval(box)); this.selectedIndex = 0; eval(box).focus(eval(box).caretPos);" style="margin-bottom: 1ex;">
<option value="" selected="selected">', $txt['change_color'], '</option>
<option value="black">', $txt['black'], '</option>
<option value="red">', $txt['red'], '</option>
<option value="yellow">', $txt['yellow'], '</option>
<option value="pink">', $txt['pink'], '</option>
<option value="green">', $txt['green'], '</option>
<option value="orange">', $txt['orange'], '</option>
<option value="purple">', $txt['purple'], '</option>
<option value="blue">', $txt['blue'], '</option>
<option value="beige">', $txt['beige'], '</option>
<option value="brown">', $txt['brown'], '</option>
<option value="teal">', $txt['teal'], '</option>
<option value="navy">', $txt['navy'], '</option>
<option value="maroon">', $txt['maroon'], '</option>
<option value="limeGreen">', $txt['lime_green'], '</option>
<option value="white">', $txt['white'], '</option>
</select>';

// Begin size dropdown
echo '
<select onchange="surroundText('[size='   this.options[this.selectedIndex].value.toLowerCase()   ']', '[/size]', eval(box)); this.selectedIndex = 0; eval(box).focus(eval(box));" style="margin-bottom: 1ex;">
<option value="" selected="selected">', $txt['font_size'], '</option>
<option value="1">8pt</option>
<option value="2">10pt</option>
<option value="3">12pt</option>
<option value="4">14pt</option>
<option value="5">18pt</option>
<option value="6">24pt</option>
<option value="7">36pt</option>
</select><br />';














echo '
</td></tr>
';

$count=0;



Find:

foreach ($context['admin_current_news'] as $admin_news)
echo '
<tr class="windowbg2">
<td align="center">
<div style="margin-bottom: 2ex;"><textarea rows="3" cols="65" id="box'.$count.'" name="news[]" style="width: 85%;" onfocus="getElements('.$count.')">', $admin_news['unparsed'], '</textarea></div>
</td><td align="left" valign="top">
<div style="overflow: auto; width: 100%; height: 10ex;">', $admin_news['parsed'], '</div>
</td><td align="center">
<input type="checkbox" name="remove[]" value="', $admin_news['id'], '" class="check" />
</td>
</tr>';
}


Replace with:

foreach ($context['admin_current_news'] as $admin_news){
$count  ;
echo '
<tr class="windowbg2">
<td align="center">
<div style="margin-bottom: 2ex;"><textarea rows="3" cols="65" id="box'.$count.'" name="news[]" style="width: 85%;" onfocus="getElements('.$count.')">', $admin_news['unparsed'], '</textarea></div>
</td><td align="left" valign="top">
<div style="overflow: auto; width: 100%; height: 10ex;">', $admin_news['parsed'], '</div>
</td><td align="center">
<input type="checkbox" name="remove[]" value="', $admin_news['id'], '" class="check" />
</td>
</tr>';
}



Find:

echo '
<tr class="windowbg2">
<td align="center">
<div id="moreNewsItems"></div><div id="moreNewsItems_link" style="display: none;"><a href="javascript:void(0);" onclick="addNewsItem(); return false;">', $txt['editnews_clickadd'], '</a></div>



Replace with:

echo '
<tr class="windowbg2">
<td align="center">
<div id="moreNewsItems"></div><div id="moreNewsItems_link" style="display: none;">';

$count++;
echo '
<a href="javascript:void(0);" onclick="addNewsItem(\'.$count.\'); return false;">', $txt['editnews_clickadd'], '</a></div>


Find:

function addNewsItem()
{
setOuterHTML(document.getElementById("moreNewsItems"), \'<div style="margin-bottom: 2ex;"><textarea rows="3" cols="65" name="news[]" style="width: 85%;"><\' + \'/textarea><\' + \'/div><div id="moreNewsItems"><\' + \'/div>\');
}


Replace with:

function addNewsItem()
{
setOuterHTML(document.getElementById("moreNewsItems"), \'<div style="margin-bottom: 2ex;"><textarea rows="3" cols="65" id="box',$count,'" name="news[]" style="width: 85%;" onfocus="getElements('.$count.')"><\' + \'/textarea>\');
document.getElementById("moreNewsItems_link").style.display = \'none\';
}






For 1.1.10 ManageNews.template.php

Find:

// Form for editing current news on the site.
function template_edit_news()
{
global $context, $settings, $options, $scripturl, $txt;

echo '



Add After:

<script language="JavaScript">
var box = "document.forms.postmodify.box1";
</script>
<script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/scripts/editor.js"></script>';

echo '

<script language="javascript">
function getElements(x)
  {
box = 'document.forms.postmodify.box'   x;
  }
</script>


Find:

// Loop through all the current news items so you can edit/remove them.

Add Before:

echo '
<tr class="windowbg2">
<td colspan="3">';




// Start gbsothere Dropdown mod
loadLanguage('Post');
echo '
<script language="JavaScript" type="text/javascript"><!-- // --><!','[CDATA[
function bbc_highlight(something, mode)
{
something.style.backgroundImage = "url("   smf_images_url   (mode ? "/bbc/bbc_hoverbg.gif)" : "/bbc/bbc_bg.gif)");
}
// ]]', '></script>';

$context['bbc_tags'] = array(
'img' => array('code' => 'img', 'before' => '[img]', 'after' => '[/img]', 'description' => $txt['image']),
'url' => array('code' => 'url', 'before' => '[url]', 'after' => '[/url]', 'description' => $txt['bbc_url']),
'italicize' => array('code' => 'i', 'before' => '[i]', 'after' => '[/i]', 'description' => 'italics'),
'center' => array('code' => 'center', 'before' => '[center]', 'after' => '[/center]', 'description' => 'center'),
);

foreach ( $context['bbc_tags'] as $image => $tag) {
echo '
<a href="javascript:void(0);" onclick="surroundText('', $tag['before'], '', '', $tag['after'], '', eval(box)); return false;">'.
'<img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="', $settings['images_url'], '/bbc/', $image, '.gif" align="bottom" width="23" height="22" alt="', $tag['description'], '" title="', $tag['description'], '" style="background-image: url(', $settings['images_url'], '/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>';
}

// Begin font dropdown
echo '
<select onchange="surroundText('[font='   this.options[this.selectedIndex].value.toLowerCase()   ']', '[/font]', eval(box)); this.selectedIndex = 0; eval(box).focus(eval(box).caretPos);" style="margin-bottom: 1ex;">
<option value="" selected="selected">', $txt['font_face'], '</option>
<option value="courier">Courier</option>
<option value="arial">Arial</option>
<option value="arial black">Arial Black</option>
<option value="impact">Impact</option>
<option value="times new roman">Times New Roman</option>
<option value="georgia">Georgia</option>
<option value="andale mono">Andale Nono</option>
<option value="trebuchet ms">Trebuchet MS</option>
<option value="comic ms">Comic MS</option>
</select>';




echo '
<select onchange="surroundText('[color='   this.options[this.selectedIndex].value.toLowerCase()   ']', '[/color]', eval(box)); this.selectedIndex = 0; eval(box).focus(eval(box).caretPos);" style="margin-bottom: 1ex;">
<option value="" selected="selected">', $txt['change_color'], '</option>
<option value="black">', $txt['black'], '</option>
<option value="red">', $txt['red'], '</option>
<option value="yellow">', $txt['yellow'], '</option>
<option value="pink">', $txt['pink'], '</option>
<option value="green">', $txt['green'], '</option>
<option value="orange">', $txt['orange'], '</option>
<option value="purple">', $txt['purple'], '</option>
<option value="blue">', $txt['blue'], '</option>
<option value="beige">', $txt['beige'], '</option>
<option value="brown">', $txt['brown'], '</option>
<option value="teal">', $txt['teal'], '</option>
<option value="navy">', $txt['navy'], '</option>
<option value="maroon">', $txt['maroon'], '</option>
<option value="limeGreen">', $txt['lime_green'], '</option>
<option value="white">', $txt['white'], '</option>
</select>';

// Begin size dropdown
echo '
<select onchange="surroundText('[size='   this.options[this.selectedIndex].value.toLowerCase()   ']', '[/size]', eval(box)); this.selectedIndex = 0; eval(box).focus(eval(box));" style="margin-bottom: 1ex;">
<option value="" selected="selected">', $txt['font_size'], '</option>
<option value="1">8pt</option>
<option value="2">10pt</option>
<option value="3">12pt</option>
<option value="4">14pt</option>
<option value="5">18pt</option>
<option value="6">24pt</option>
<option value="7">36pt</option>
</select><br />';














echo '
</td></tr>
';



Find:

foreach ($context['admin_current_news'] as $admin_news)
echo '
<tr class="windowbg2">
<td align="center">
<div style="margin-bottom: 2ex;"><textarea rows="3" cols="65" name="news[]" style="width: 85%;">', $admin_news['unparsed'], '</textarea></div>
</td><td align="left" valign="top">
<div style="overflow: auto; width: 100%; height: 10ex;">', $admin_news['parsed'], '</div>
</td><td align="center">
<input type="checkbox" name="remove[]" value="', $admin_news['id'], '" class="check" />
</td>
</tr>';



Replace with:

foreach ($context['admin_current_news'] as $admin_news){
$count++;
echo '
<tr class="windowbg2">
<td align="center">
<div style="margin-bottom: 2ex;"><textarea rows="3" cols="65" id="box'.$count.'" name="news[]" style="width: 85%;" onfocus="getElements('.$count.')">', $admin_news['unparsed'], '</textarea></div>
</td><td align="left" valign="top">
<div style="overflow: auto; width: 100%; height: 10ex;">', $admin_news['parsed'], '</div>
</td><td align="center">
<input type="checkbox" name="remove[]" value="', $admin_news['id'], '" class="check" />
</td>
</tr>';
}



Find:

echo '
<tr class="windowbg2">
<td align="center">
<div id="moreNewsItems"></div><div id="moreNewsItems_link" style="display: none;"><a href="javascript:void(0);" onclick="addNewsItem(); return false;">', $txt['editnews_clickadd'], '</a></div>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
document.getElementById("moreNewsItems_link").style.display = "";

function addNewsItem()
{
setOuterHTML(document.getElementById("moreNewsItems"), \'<div style="margin-bottom: 2ex;"><textarea rows="3" cols="65" name="news[]" style="width: 85%;"></textarea></div><div id="moreNewsItems"></div>\');
}



Replace with:

echo '
<tr class="windowbg2">
<td align="center">
<div id="moreNewsItems"></div><div id="moreNewsItems_link" style="display: none;">';

$count++;
echo '
<a href="javascript:void(0);" onclick="addNewsItem(\'.$count.\'); return false;">', $txt['editnews_clickadd'], '</a></div>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
document.getElementById("moreNewsItems_link").style.display = "";

function addNewsItem()
{
setOuterHTML(document.getElementById("moreNewsItems"), \'<div style="margin-bottom: 2ex;"><textarea rows="3" cols="65" id="box',$count,'" name="news[]" style="width: 85%;" onfocus="getElements('.$count.')"><\' + \'/textarea>\');
document.getElementById("moreNewsItems_link").style.display = \'none\';
}


Find:

function addNewsItem()
{
setOuterHTML(document.getElementById("moreNewsItems"), \'<div style="margin-bottom: 2ex;"><textarea rows="3" cols="65" name="news[]" style="width: 85%;"></textarea></div><div id="moreNewsItems"></div>\');
}



Replace with:

function addNewsItem()
{
setOuterHTML(document.getElementById("moreNewsItems"), \'<div style="margin-bottom: 2ex;"><textarea rows="3" cols="65" id="box',$count,'" name="news[]" style="width: 85%;" onfocus="getElements('.$count.')"><\' + \'/textarea>\');
document.getElementById("moreNewsItems_link").style.display = \'none\';
}



Find:

</noscript>
</td>
<td colspan="2" valign="bottom" align="right" style="padding: 1ex;">
<input type="submit" name="save_items" value="', $txt[10], '" /> <input type="submit" name="delete_selection" value="', $txt['editnews_remove_selected'], '" onclick="return confirm(\'', $txt['editnews_remove_confirm'], '\');" />
</td>
</tr>
</table>
<input type="hidden" name="sc" value="', $context['session_id'], '" />
</form>';
}



Replace with:

<noscript>
<div style="margin-bottom: 2ex;"><textarea rows="3" cols="65" style="width: 85%;" name="news[]"></textarea></div>
</noscript>
</td>
<td colspan="2" valign="bottom" align="right" style="padding: 1ex;">
<input type="submit" name="save_items" value="', $txt['save'], '" /> <input type="submit" name="delete_selection" value="', $txt['editnews_remove_selected'], '" onclick="return confirm(\'', $txt['editnews_remove_confirm'], '\');" />
</td>
</tr>
</table>
<input type="hidden" name="sc" value="', $context['session_id'], '" />
</form>';
}




And.....  although most of it is redundant, I went ahead and added this to 1.1.0's Themes/default/languages/Post.english.php

Find:


?>



Add before:

// Strings for News Dropdown
$txt['font_size'] = 'Font Size';
$txt['font_face'] = 'Font Face';
$txt['image'] = 'Insert Image';
$txt['bbc_url'] = 'Insert URL';
$txt['change_color'] = 'Change Color';
$txt['black'] = 'Black';
$txt['red'] = 'Red';
$txt['yellow'] = 'Yellow';
$txt['pink'] = 'Pink';
$txt['green'] = 'Green';
$txt['orange'] = 'Orange';
$txt['purple'] = 'Purple';
$txt['blue'] = 'Blue';
$txt['beige'] = 'Beige';
$txt['brown'] = 'Brown';
$txt['teal'] = 'Teal';
$txt['navy'] = 'Navy';
$txt['maroon'] = 'Maroon';
$txt['lime_green'] = 'Lime Green';
$txt['white'] = 'White';
$txt['save'] = 'Save';
$txt['url'] = 'URL';

//End Strings for News Dropdown






There it is, Arantor.  I hope the codes aren't too hard to find.  As we all know, I'm not good at this.

Thank you again, and thank you, Kays and "jeza the Wizard" for all your help.


:)


Edit:  Right now, in 1.1.10, you must save one entry before the "Click to add another item" link reappears for a new one.  Also, make sure your cursor is in the new box before clicking a BBCode button.
Title: Re: BBC Options for News?
Post by: Arantor on September 26, 2009, 10:38:06 AM
Looks real good :)

If you're fine with me packaging it up, I'll take a look at doing that tonight or tomorrow since there is a fair amount of editing going on, and possibly some of it can be condensed, for example rather than readding the language strings, I'd look at loading the relevant language file instead - keeps it easier for those who use multi language forums.
Title: Re: BBC Options for News?
Post by: gbsothere on September 26, 2009, 10:41:58 AM
I'm not only grateful to turn it over to you, I'm relieved!  If someone were to run into a problem and ask me a technical question, I'd just blink at them.   :D

I was so worried that I would miss something in showing the coding, that I'm sure I included huge blocks that didn't need to be part of the "find and add".  It was just too easy to do a "replace with". 

Thank you so much for taking it over!  I have it working on all my forums, so I'm very happy but someone else might find it useful and a packaged mod would be far less complicated that all this song and dance I posted. 

Thanks!   :)
Title: Re: BBC Options for News?
Post by: Kays on September 26, 2009, 11:05:42 AM
I'm glad to see that you've finally got something working that you're happy with. :)
Title: Re: BBC Options for News?
Post by: gbsothere on September 26, 2009, 11:37:35 AM
Quote from: Kays on September 26, 2009, 11:05:42 AM
I'm glad to see that you've finally got something working that you're happy with. :)


I kept reading everyone's advice out loud, so it would sink in.   :D  Thank you, Kays!
Title: Re: BBC Options for News?
Post by: gbsothere on September 26, 2009, 12:02:07 PM
I reattached a new file (the last one) for 1.1.10, making it no longer necessary to have to save one entry before having the option to add a new one.  (Thanks, again, jeza.)