Go Back   Mosets Community > Mosets Announcements and Discussions > Mosets & Joomla

Thread Tools Search this Thread Display Modes
Old 01-26-2018, 12:59 PM
peterwalker peterwalker is offline
Join Date: Nov 2013
Posts: 52
Default Added textarea to template.xml but newlines are trimmed. How can this be changed?

I added a standard Joomla form field to the template.xml, but newlines are trimmed on save and all the text starting from the first newline are erased. I added filter attribute filter="raw" but the same trim occur, so evidently a MT function. I see no reason a template config form field should require such sensitization, especially since it's using the JForm process.

How can I stop the newline trim?
Reply With Quote
Old 01-29-2018, 11:46 PM
peterwalker peterwalker is offline
Join Date: Nov 2013
Posts: 52
Default Solved

@Mosets dev
You are using an archaic method of setting the template parameters in the database. Since you already parse the data with JRegistry, why not insert as modern json_encode() format? That makes the data much more flexible.

Though the solution achieves the result, it is subject to overwrite since it requires editing the function save_templateparam() of file administrator/components/com_mtree/mtree.php, so I'd certainly encourage the core change for future release.

PHP Code:
function save_templateparam$option ) {
$app        JFactory::getApplication('site');
$database    JFactory::getDBO();
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));

$params JFactory::getApplication()->input->get'params', array(), 'array' );
$template JFactory::getApplication()->input->getCmd'template''');
//=======================[ MODIFICATION TO SAVE DATA AS JSON_ENCODED FORMAT]========================//
if ( is_array$params ) ) {
/*$attribs = array();
        foreach ( $params as $k => $v) {
            if( is_array($v) ) {
                $attribs[] = "$k=".implode('|',$v);
            } else {
                $attribs[] = "$k=$v";
        $str_params = implode("\n",$attribs);*/
$str_params json_encode($params);

$database->setQuery('INSERT INTO #__mt_templates (`tem_name`, `params`) VALUES ( ' $database->quote($template) . ', ' $database->quote($str_params) . ') ON DUPLICATE KEY UPDATE params = ' $database->quote($str_params) . ';');

$task JFactory::getApplication()->input->getCmd'task''' );
    if ( 
$task == "save_templateparams" ) {
$app->redirect'index.php?option='$option .'&task=templates' );
    } else {
$app->redirect'index.php?option='$option .'&task=template_pages&template=' $template );

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +8. The time now is 02:48 PM.

Copyright © 2005-2010 Mosets Consulting

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.