getTemplate(); // button is not active in specific content components $getContent = $this->_subject->getContent($name); $present = JText::_('ALREADY EXISTS', true) ; $js = " function insertReadmore(editor) { var content = $getContent if (content.match(//i)) { alert('$present'); return false; } else { jInsertEditorText('
', editor); } } "; $doc->addScriptDeclaration($js); $button = new JObject(); $button->set('modal', false); $button->set('onclick', 'insertReadmore(\''.$name.'\');return false;'); $button->set('text', JText::_('Readmore')); $button->set('name', 'readmore'); // TODO: The button writer needs to take into account the javascript directive //$button->set('link', 'javascript:void(0)'); $button->set('link', '#'); return $button; } }