Hi, i´m kind of new into FCK editor.
Here is my problem.
I wanna create 2 new dropdown menus.
In those dropdowns i wannt the walue to be data from my mysql database.
Can anyone help to explain how i can do this? (i´m using PHP).
Sorry for my bad english.
Reguards
Anders
Here is my problem.
I wanna create 2 new dropdown menus.
In those dropdowns i wannt the walue to be data from my mysql database.
Can anyone help to explain how i can do this? (i´m using PHP).
Sorry for my bad english.
Reguards
Anders
RE: FIll dropdown with mysql data?
Take a look at the combo plugin:
http://sourceforge.net/tracker/index.ph ... tid=737639
RE: FIll dropdown with mysql data?
RE: FIll dropdown with mysql data?
In your parent window create a javascript array like this:
var arrComboItems = new Array(
new Array('Item 1 from mysql', '<span style="text-decoration: underline;color: #0000FF;font-size: 9pt;">Label for Item 1</span>')
, new Array('Item 2 from mysql', '<span style="text-decoration: underline;color: #0000FF;font-size: 9pt;">Label for Item 2</span>')
, new Array('Item 3 from mysql', '<span style="text-decoration: underline;color: #0000FF;font-size: 9pt;">Label for Item 3</span>')
);
Then in the Combo plugin where the "this._Combo.AddItem(...)" lines are use this instead:
try {
if (parent.arrComboItems != undefined) {
if (parent.arrComboItems.length == 0) {
this._Combo.AddItem('', '<span style="font-size: 9pt;">No items available</span>');
} else {
for (var i = 0; i < parent.arrComboItems.length; i++)
this._Combo.AddItem(parent.arrComboItems[i][0], parent.arrComboItems[i][1]);
}
} else {
this._Combo.AddItem('', '<span style="font-size: 9pt;">No items available</span>');
}
} catch(err) {
this._Combo.AddItem('', '<span style="font-size: 9pt;">No items available</span>');
}
RE: FIll dropdown with mysql data?
RE: FIll dropdown with mysql data?
I just get an error then i´m trying this code.
The error is - Unknown Toolbar "mycombo".
RE: FIll dropdown with mysql data?
Now i just need to get my mysql data into the javascript array....
RE: FIll dropdown with mysql data?
<html> <head> <script language="text/javascript"> <?php /* -$resultSet is created from your mysql database -build a string containing the javascript array and then echo it to your page */ $jsArray = "var arrComboItems = new Array("; foreach ($resultSet as $row) { if (!isset($i)) $jsArray .= "new Array('".$row['mysqldata']."', '<span style=\"text-decoration: underline;color:#0000FF;font-size:9pt;\">".$row['labelformysqldata']."</span>')"; else $jsArray .= ", new Array('".$row['mysqldata']."', '<span style=\"text-decoration: underline;color:#0000FF;font-size:9pt;\">".$row['labelformysqldata']."</span>')"; $i = 1; } $jsArray .= ');'; echo $jsArray; ?> </script> </head> <body> Your fckEditor is in here somewhere. The plugin will then refer to parent.arrComboItems which you have created above </body> </html>
RE: FIll dropdown with mysql data?
After adding the new code insted of "this._Combo.AddItem(...)" lines i got back to the errormessage " unknown toolbar item "mycombo"
RE: FIll dropdown with mysql data?
1, there is a problem with the javascript array - can you confirm it is OK by alert()'ing some of it's values? Do this in the same <script>...</script> block as the array.
Or 2, it may mean there is a problem with the new javascript added to the plugin. Try removing the new code to see if that error dissappears. Then little by little put the code back in - if it breaks again you will know what the problem is.
RE: FIll dropdown with mysql data?
i have tried to take away the new code pice of pice, i get the error untill evveryting of the new code is gone, so i guess its the array..
RE: FIll dropdown with mysql data?
Plz..
RE: FIll dropdown with mysql data?
Here is a javascript array that I know works (you will need to work out how to produce this from your mysql data based on my earlier post) Put it in the <head> section of your webpage:
<script type="text/javascript">
var arrComboItems = new Array(
new Array('Item 1', '<span style="text-decoration: underline;color: #0000FF;font-size: 9pt;">Item 1</span>')
, new Array('Item2', '<span style="text-decoration: underline;color: #0000FF;font-size: 9pt;">Item 2</span>')
);
</script>
In fckconfig.js:
-Add this
FCKConfig.Plugins.Add( 'mycombo' );
-Add 'mycombo' to your ToolbarSet
Then the plugin code itself. Create a directory called 'mycombo' in the 'plugins' directory. The following code works with the above array (I have testing it just now). Save this as fckplugin.js in your 'mycombo' plugin directory:
--------------------------------------
//MyCombo 'command'
var FCKMyCombo = function(name) {
this.Name = name ;
}
//This get's executed when an item from the MyCombo list gets selected
FCKMyCombo.prototype.Execute = function(itemID, item) {
if (itemID != "")
FCK.InsertHtml(itemID);
}
FCKMyCombo.prototype.GetState = function()
{
return;
}
FCKCommands.RegisterCommand( 'mycombo' , new FCKMyCombo('mycombo') ) ;
//MyCombo 'Object'
//This creates the MyCombo object
var FCKToolbarMyCombo=function(A,B){
this.Command=FCKCommands.GetCommand('mycombo');//the command to execute when an item is selected
this.CommandName = 'mycombo';
this.Label=this.GetLabel();
this.Tooltip=A?A:this.Label;
this.Style=B?B:FCK_TOOLBARITEM_ICONTEXT;
};
FCKToolbarMyCombo.prototype=new FCKToolbarSpecialCombo;
FCKToolbarMyCombo.prototype.GetLabel=function(){
return "My Combo";
};
//This adds the items to the MyCombo list
FCKToolbarMyCombo.prototype.CreateItems=function(A){
try {
if (parent.arrComboItems != undefined) {
if (parent.arrComboItems.length == 0) {
this._Combo.AddItem('', '<span style="font-size: 9pt;">No items available</span>');
} else {
for (var i = 0; i < parent.arrComboItems.length; i++)
this._Combo.AddItem(parent.arrComboItems[i][0], parent.arrComboItems[i][1]);
}
} else {
this._Combo.AddItem('', '<span style="font-size: 9pt;">No items available</span>');
}
} catch(err) {
this._Combo.AddItem('', '<span style="font-size: 9pt;">No items available</span>');
}
}
//This registers the combo with the FCKEditor
FCKToolbarItems.RegisterItem( 'mycombo' , new FCKToolbarMyCombo( 'mycombo', FCK_TOOLBARITEM_ICONTEXT ) ) ;
--------------------------------------
Then you might need to clear your browser's cache and refresh the web page.
This all works for me. When I was creating it I did get some of the errors your mentioned but they were because the directory name wasn't right and the "FCKConfig.Plugins.Add( 'mycombo' );" and toolbarset names were not the same.
This is about all I can do to help you on this one. I hope it works for you.
RE: FIll dropdown with mysql data?
Hm well it almost works
I dont get the error, and the array are created ( i have made a test and print it, so i know its ok).
The only thing not working is that the array dosent appear in the editor...
No items *hmm*
RE: FIll dropdown with mysql data?
if (parent.arrComboItems != undefined) {
if (parent.arrComboItems.length == 0) {
this._Combo.AddItem('', '<span style="font-size: 9pt;">No items available</span>');
} else {
for (var i = 0; i < parent.arrComboItems.length; i++)
this._Combo.AddItem(parent.arrComboItems[i][0], parent.arrComboItems[i][1]);
}
} else {
this._Combo.AddItem('', '<span style="font-size: 9pt;">No items available</span>'); <--- THIS IS RUNNING
}
} catch(err) {
this._Combo.AddItem('', '<span style="font-size: 9pt;">No items available</span>');
}
}
RE: FIll dropdown with mysql data?
Where did you put the javascript array? Is it in the parent web page <head> section?
You might need to change how you reference the array. Maybe window.parent.arrComboItems might work, or window.top.arrComboItems.
RE: FIll dropdown with mysql data?
Changed the code in the <head>
like this:
<script type="text/javascript">
var arrComboItems = new Array(
);
</script>