Joomla JEditor display() doesn't load the editor - joomla

I've been battling this all morning and can't seem to find anything on how this works. I need the editor (system default) to show up in my back-end component.
My default editor is TinyMCE
I'm on Joomla 2.5.x
This is how far I've gotten with searching this forum and google.
Sample of my script
jimport( 'joomla.html.editor' );
$editor =& JEditor::getInstance();
echo $editor->display("desc", $itemData['body'], "600", "400", "80", "15", 1, null, null, null, array('mode' => 'advanced'));
All I'm getting is a HTML textarea with my content from the $itemData['body']. No editor. What am I missing?
THIS IS NOW SOLVED.
I did some more research and learned to use Joomla's JForm to create nice forms and have more control in my component in the back end.

jimport( 'joomla.html.editor' );
$editor = &JFactory::getEditor();
echo $editor->display('editorname', $this->detail->namechamp, '100%', '300', '75', '20');

Related

How to in-build wysiwyg editor in a self-build joomla component

I know there are some code to get the editor in joomla itself like
<?php
$editor = JFactory::getEditor();
echo $editor->display('description', $row->description, '550', '400', '60', '20', false);
?>
But after i submit the form, the content will go back to plain text.
I must miss out something, hope someone could help me.
Try below code at action page to get value. Hope it helps.
$description = JRequest::getVar('description', 'default value goes here', 'post','validation type',JREQUEST_ALLOWHTML);

Enable html in joomla editor

In one of my joomla custom form, I am rendering an editor as follows
<?php
$qu=$question ? $question : '';
$editor = JFactory::getEditor();
echo $editor->display('question', $qu, '100%', '400', '80', '15');
?>
The editor was working fine But when I am trying to submit after formatting, its html part won't get sumitted. If the editor was loading from xml filter="safehtml" or filter="raw" will work. But how to enable html in this case ?
Please help
Thanks in advance
The problem lies in JRequest::GET which by default strips all html.
You have to ask specifically the input you want html from.
JRequest::getVar( 'yourfieldname', '', 'post', 'string', JREQUEST_ALLOWHTML );
Joomla Docs

Joomla - renderModule function strips javascript

please help, I've a problem with Joomla's function renderModule.. I am trying to render module with this function, but it unfortunately strips javascript from the the rendered module.
I use the function in my own module which includes other modules according to current article..
The code is as following:
<?php
$moduleType = "j15html";
$moduleName = "test";
$option = JRequest::getVar( 'option', '' );
$view = JRequest::getVar( 'view', '' );
$id = JRequest::getInt( 'id', 0 );
$moduleName .= $id;
//echo $view;
if ( $option == "com_content" && $view == "article" ) {
//echo $moduleName;
$module = JModuleHelper::getModule($moduleType, $moduleName);
//print_r($module);
if ( ! empty( $module ) ) {
$attribs = array();
echo JModuleHelper::renderModule( $module, $attribs );
}
}
When I set the position of the included module to any position used in my template and set it to displat in particular menu section, it renders properly even with javascript and so on..
Any advices how to make this thing working?
You didn't mention which version of Joomla you're using - but you may want to check out SOURCERER it keeps coding how you put it and does not strip out extra coding.
Make sure you read the how-to so you know how to use it because it can seem a little confusing at first, but it has a button to 'change the tags' from < to << or [ which do not get stripped out by the WYSIWYG editor in Joomla!.
Of course, that could be your issue also, if your WYSIWYG editor is on (by default it is) and you're inputting code - it strips it. An easy way is to just turn it off under global options, then when you save the code doesn't get stripped. Just turning off the WYSIWYG editor is the quick/easy/simple solution - but if you turn it back on and open that module again, the code will be gone. So it can be a tricky solution if others may like using the editor or if you're using lots of custom code around your side. In that case the plugin I mentioned above is a great solution.

Joomla TinyMCE editor do not save inserted image

We are building joomla component. And we use joomla editor in which we insert content.
But there is a problem, because when we add image to editor and save it, it do not add image to database and when we opening this element to edit it again, there is only text in editor, image disappears.
This is how we use it:
$editor =& JFactory::getEditor();
echo $editor->display('text', $this->hello->text, '800', '300', '20', '20');
Maybe there is need to supply aditional parameters to display method?
Problem solved.
The standard way of getting the form data $post = JRequest::get('post'); is not enough in the case of using a editor. This will filter the content, hence losing line breaks and paragraps. So we need to add an extra line to get the editor contents in a raw unfiltered way. This data will be passed to the model to save into the database.
To get HTML form post data you need to get this data in following way
$data = JRequest::getVar( 'editorName', 'defaultValue', 'post', 'string', JREQUEST_ALLOWRAW );
And need to add a javascript for the view(tmpl file)
function submitbutton(action) {
var form = document.adminForm;
switch(action)
{
case 'save':case 'apply':
<?php
$editor =& JFactory::getEditor();
echo $editor->save( 'editorName' );
?>
case 'publish':
case 'unpublish':
case 'cancel':
default:
submitform( action );
}
}

Change template after user login in joomla 1.5

Anybody ever tried to change joomla 1.5 template in code? Don't know how to do it on current version. I just wanted to change the template after the user login.
So, i wrote code like this :
$mainframe->setTemplate('newtemplate');
But it doesn't works. WHen i see the joomla application.php, whoops, there is no setTemplate function there, but it used to be there before 1.5 (based on my search on the web).
Anyone know how to do it?
Update :
seems that we can set user state and just read that user state, then render. But I don't know where joomla render the template, since I put a code in library/joomla/application.php, insite render(), but it didn't get executed. This is what i did :
function render()
{
$params = array(
'template' => $this->getTemplate(),
'file' => 'index.php',
'directory' => JPATH_THEMES
);
// I added this code, where i set the user state $option.template somewhere else
$template = $mainframe->getUserState( "$option.template", 'FoxySales01VIP' );
if(!empty($template)){
$params['template'] = $template;
}
$document =& JFactory::getDocument();
$data = $document->render($this->getCfg('caching'), $params );
JResponse::setBody($data);
}
Never mind, i solved it.
Just change the code in core library (JDocument Class) to read the template from session, works fine.
Thanks

Resources