Tuesday, December 21, 2010

Add button in the WYSIWYG editor



The buttons do the insertion into the body of news, anything.
Doing for themselves, as they should be inserted into the short and full story frame with styles and so on. 



Open:
engine/editor/shortnews.php 

Find:
dle_hide, dle_break, dle_page ",
Replace with:
dle_hide, dle_break, dle_page, dle_mb, dle_mb2 ",

Find:
ed.addButton('dle_page', {
            title : '{$lang['bb_t_p']}',
            image : '{$config['http_home_url']}engine/editor/jscripts/tiny_mce/themes/advanced/img/dle_page.gif',
            onclick : function() {

                var enterURL   = prompt("{$lang['bb_page']}", "1");
                var enterTITLE = prompt("{$lang['bb_page_name']}", "");
                if (enterURL == null) enterURL = "1";
                if (enterTITLE == null) enterTITLE = "";
                ed.execCommand('mceInsertContent',false,"[page="+enterURL+"]"+enterTITLE+"[/page]");
            }
               });
Add below:
///Мини Блок///
ed.addButton('dle_mb', {
title : '{$lang['bb_t_br']}',
image : '{$config['http_home_url']}engine/editor/jscripts/tiny_mce/themes/advanced/img/mb.gif',
onclick : function() {

ed.execCommand('mceInsertContent',false,'<table width="50%" border="1" align="center" cellpadding="5" cellspacing="5"><tr><td bgcolor="#CC9900">&nbsp;</td><td bgcolor="#333333">&nbsp;</td><td bgcolor="#CC9900">&nbsp;</td><td bgcolor="#333333">&nbsp;</td></tr><tr><td bgcolor="#CC9900">&nbsp;</td><td bgcolor="#333333">&nbsp;</td><td bgcolor="#CC9900">&nbsp;</td><td bgcolor="#333333">&nbsp;</td></tr></table>');}});
////////////////

///Мини Блок 2///
ed.addButton('dle_mb2', {
title : '{$lang['bb_t_br']}',
image : '{$config['http_home_url']}engine/editor/jscripts/tiny_mce/themes/advanced/img/mb2.gif',
onclick : function() {

ed.execCommand('mceInsertContent',false,'<table width="50%" align="right" cellpadding="5" cellspacing="5"><tr><td bgcolor="#990000">&nbsp;</td><td rowspan="2" bgcolor="#333333">&nbsp;</td><td bgcolor="#990000">&nbsp;</td><td rowspan="2" bgcolor="#333333">&nbsp;</td></tr><tr><td bgcolor="#990000">&nbsp;</td><td bgcolor="#990000">&nbsp;</td></tr></table>');}});
////////////////

That's it! 

* - Pictures of buttons to put on at engine /editor/jscripts/tiny_mce/themes/advanced/img/
* - WARNING! The code must be formatted with no breaks between tags: 



This is wrong:
<table width="50%" border="1" align="center" cellpadding="5" cellspacing="5">
<tr>
<td bgcolor="#CC9900">&nbsp;</td>
<td bgcolor="#333333">&nbsp;</td>
<td bgcolor="#CC9900">&nbsp;</td>
<td bgcolor="#333333">&nbsp;</td>
</tr>
<tr>
<td height="30" bgcolor="#CC9900">&nbsp;</td>
<td bgcolor="#333333">&nbsp;</td>
<td bgcolor="#CC9900">&nbsp;</td>
<td bgcolor="#333333">&nbsp;</td>
</tr>
</table>

This is correct:
<table width="50%" border="1" align="center" cellpadding="5" cellspacing="5"><tr><td bgcolor="#CC9900">&nbsp;</td><td bgcolor="#333333">&nbsp;</td><td bgcolor="#CC9900">&nbsp;</td><td bgcolor="#333333">&nbsp;</td></tr><tr><td height="30" bgcolor="#CC9900">&nbsp;</td><td bgcolor="#333333">&nbsp;</td><td bgcolor="#CC9900">&nbsp;</td><td bgcolor="#333333">&nbsp;</td></tr></table> 

Related Posts:

  • Add button in the WYSIWYG editor The buttons do the insertion into the body of news, anything. Doing for themselves, as they should be inserted into the short and full story frame with styles and so on.  Open: engine/editor/shortnews.php  Find:… Read More
  • Datalife Engine Noindex Hack After 5 years I am back on using Datalife Engine CMS. And one of the problem I faced when trying to rank well for SEO was no index for tags, xfields or other pages I didn't want to. In wordpress it is simple, installing pl… Read More
  • How to insert PHP code in file main.tplmain.tpl file is a template file of DLE. There are cases when you need to insert PHP codes in It, but It is not allowed. So now I will show you a hack how to enable the insertion of PHP codes in main.tpl 1. Open file index.p… Read More
  • How to add iframe in DLE post Adding iframe to Datalife Engine post is much easier than you may think. You don't need any modules. By default DLE allows iframe from only few domains because of security purposes. Let's say you want to embed a video or m… Read More
  • New Links I present you hack transformation options for DataLife Engine. Powered by CSS2.0 support each browser. The trick is that when you hover on a link it is animated and the background turns to the left or right. Very nice t… Read More

1 comment: