Using modal box in joomla to display a page in popup

Using a modal  to display a form/page in the popup

1) In view page

Add this in php JHTML::_(‘behavior.modal’);

A anchor tag for the link

<a rel=”{handler: ‘iframe’, size: {x: 800, y: 600}}” href=”index.php?option=com_component&task=someTask&id=someId” class=”modal” target=”_blank”>LINK</a>

To display a page in popup with out header and footers add extra parameter tmpl=component to the href

<a rel=”{handler: ‘iframe’, size: {x: 800, y: 600}}” href=”index.php?option=com_component&tmpl=component&task=sometask&id=someId” class=”modal” target=”_blank”>LINK</a>

2) In Controller  ( to close the popup and refresh the parent window )

function someFunction(){

// code to insert the data to database or some logic comes here

$doc = JFactory::getDocument();
$js = “javascript: window.parent.document.location.reload(true);”;
$js .= “javascript:window.parent.SqueezeBox.close();”;
$doc->addScriptDeclaration($js);

}

 

Using Joomla default editor for the custom component

Using joomla inbuilt editor for text areas in the Form

1) In view page:

Add the below code to replace the text area with Editor

$editor = JFactory::getEditor();
echo $editor->display(‘textarea_name’, $textarea_content, ‘655’, ‘400’, ’20’, ’20’, false);

 

2) In Model page

To insert editor data with out striping tags in to the database.

// get editor content

$editor_content = JRequest::getVar( ‘textarea_name’, ”, ‘post’, ‘html’, JREQUEST_ALLOWRAW );

// insert into database

$query = “INSERT INTO  `#__table_name`  (title,content)  VALUES (‘$title’,addslashes($editor_content))”;