Customizing SMF > Tips and Tricks

Fonts drop down selection & URL in post screen

<< < (2/20) > >>

codenaught:
Thank you very much! :D Now do you know how I could do something for the url thing so when you click on the url button it first asks for a name to the link and then it asks for the url of the link instead of just entering
--- Code: ---[url][/url]
--- End code ---

A.M.A:
1- Font Size & Name drop down list
open Post.template.php and look for:

--- Code: --- <option value="LimeGreen">', $txt[275], '</option>
</select>';
echo '<br />';

--- End code ---
Delete the last line, and Add belew it:

--- Code: ---  // Begin Print a drop down list for font face . . . . . . .
    echo ' <select onchange="surroundText(\'[font=\'+this.options[this.selectedIndex].value+\']\', \'[/font]\', document.', $context['post_form'], '.', $context['post_box_name'], '); this.selectedIndex = 0;" style="margin-bottom: 1ex;">
            <option value="" selected="selected">Font Face</option>
            <option value="Arial">Arial</option>
            <option value="Times New Roman">Times New Roman</option>
            <option value="Tahoma">Tahoma</option>
            <option value="Verdana">Verdana</option>
            </select>';
  // End Print a drop down list for font face . . . . . . . .

  // Begin Print a drop down list for font size . . . . . . .
    echo ' <select onchange="surroundText(\'[size=\'+this.options[this.selectedIndex].value+\']\', \'[/size]\', document.', $context['post_form'], '.', $context['post_box_name'], '); this.selectedIndex = 0;" style="margin-bottom: 1ex;">
            <option value="" selected="selected">Font Size</option>
            <option value="10pt">10pt</option>
            <option value="14pt">14pt</option>
            <option value="18pt">18pt</option>
            </select>';
    echo '<br />';
  // End Print a drop down list for font size . . . . . . . .

--- End code ---

Note:
* you can modify the red text: <option value="10pt">10pt</option> to your own needs.
* to remove the default tag buttons, look for and delete:

--- Code: --- array(),
'size' => array('code' => 'size', 'before' => '[size=10pt]', 'after' => '[/size]', 'description' => $txt[532]),
'face' => array('code' => 'font', 'before' => '[font=Verdana]', 'after' => '[/font]', 'description' => $txt[533]),
--- End code ---


2- URL input boxes
look for:

--- Code: ---// Print a drop down list for all the colors we allow!
--- End code ---
add above:

--- Code: ---    // Java script to handle URL input boxes ...
    echo '<script language="JavaScript" type="text/javascript">
          <!--
          function urlINPT(){
          // Enter URL .........................................
          var urlLINK = prompt("Please enter URL address:","http://");
          if (urlLINK == null ){ //cancel pressed . . .
          }
          else if (urlLINK == "" || urlLINK == " "){ //ok pressed but with Notext . . .
                  alert("Sorry no text entered!");
          }
          else
          { //ok pressed and there is something :)
          // Enter Description ...................................
          var urlNAME = prompt("Please enter URL name:","");
          if (urlNAME == null ){ //cancel pressed . . .
          }
          else if (urlNAME == "" || urlNAME == " "){  //ok pressed but with notext so use URL only!
                    surroundText(\'[url]\'+urlLINK+\'\', \'[/url]\', document.', $context['post_form'], '.', $context['post_box_name'], ');
          }
          else //ok pressed with text so use URL and Name!
                    surroundText(\'[url=\'+urlLINK+\']\'+urlNAME+\'\', \'[/url]\', document.', $context['post_form'], '.', $context['post_box_name'], ');
          }
          }
          // -->
          </script>';
--- End code ---
look for:

--- Code: --- // Print the buttom row of buttons!
foreach ($context['bbc_tags'][1] as $image => $tag)
{

--- End code ---
add after:

--- Code: ---      // only replace the URL tag! . . . . . . . . . . .
      if ($tag['code'] == 'url')
          echo '<a href="javascript:void(0);" onclick="urlINPT(); 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'], '" border="0" style="background-image: url(', $settings['images_url'], '/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>';
      else

--- End code ---

codenaught:
Thank you very much! This is a big help!

codenaught:
Okay, but could someone tell me how to do a small change to the url one.

Here is what I want to do. When you highlight code and hit the url button, it asks for the address and then it asks you for the name of the link. How about when you highlight text it will just ask you for the url and it will use the highlighted text as the name of the link.

Any help would be nice.

damo1065:
Works like a dream thanks.

Does anyone know what colours you can add to the drop down colour menu, I know HotPink works - it gives you a nice deep pink colour, what other ones can you add?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version