Hi all this is my first post. I am just starting with php and am working on a plugin for joomla.

I am attempting to dynamically place a button in the joomla editor that when clicked inserts pre-made html code into the editor.

i have the button displaying fine i appear to be getting the html from a text file fine "according to firebug" BUT when i click the button nothing happens?

So this is what i have done

PHP Code:

<?php
 
defined
('_JEXEC') or die;
class 
plgButtonsnapchunkz extends JPlugin
{
    public function 
onDisplay($name)
    {
              
        
$chunk file(JURI::root(). 'plugins/editors-xtd/Snapchunkz/models/chunks/test.txt');  
        
$finished implode($chunk);
       
// $chunk = $this->params->get('chunk1', '');
        
$label "chunk1";       
        
$jsCode "function addchunk(editor) { 
        
            jInsertEditorText(
$finished, 'editor'); 
            
        }"
;
        

    
        
$doc JFactory::getDocument();
        
$doc->addScriptDeclaration($jsCode);
        
        
$button = new JObject();                
        
$button->modal false;
        
$button->class 'btn';
        
$button->text $label;
        
$button->name $label;
        
$button->onclick 'addchunk(\''.$name.'\');return false;';
        
        return 
$button;
    }
}

?>
my text file (to get the html code) please note i am trying to insert the following text in a formatted way so its easily readable.

HTML Code:
<div class="ph-row">
		<div class="ph-col4" style="margin: 0px;">		
			<div class="ph-boxed-module">							
				     <span class="ph-boxed-module-icon ph-left icon-home icon-4x"></span>
				         <h3 class="ph-black">Small Business</h3>
						 <h5 class="ph-grey">Websites</h5>
			</div>			
		</div>	
</div>
This is what firebug says is happening. if it helps
PHP Code:

function addchunk(editor) { 
        
            
jInsertEditorText('<div class="ph-row">
        <div class="ph-col4" style="margin: 0px;">        
            <div class="ph-boxed-module">                            
                     <span class="ph-boxed-module-icon ph-left icon-home icon-4x"></span>
                         <h3 class="ph-black">Small Business</h3>
                         <h5 class="ph-grey">Websites</h5>
            </div>            
        </div>    
</div>
'
'editor'); 
so in short i want to insert the text from the txt file into the editor when the button is clicked.