N
N
Nikasak2015-08-19 16:44:08
DLE
Nikasak, 2015-08-19 16:44:08

When adding news, it pops up "The title is required when writing an article" How to be?

When adding news, it pops up "Title is required when writing an article"
Although everything is filled out

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Артем, 2015-08-24
@ber_enot

Instructions for DLE 10.4, I don’t know if it’s suitable for older versions or not, but the code will be similar.
What do we need? You need to cut out all checks for the emptyness of $title and remove the js that parses the input and throws an error if it is empty.
You can do it easier - find this input, set some word or hash as its value, plus make it hidden (type=hidden), and remove the news title from the news template.
This is done in the same files for which the check cutting process is described.
We make copies of these files so that we can undo the changes in case of an error:
Line 198:
Delete or comment on it.
There may be problems with ajax search for similar news (they are searched by title), for this you can replace the code in the same file:

function find_relates ( )
  {
    var title = document.getElementById('title').value;
    ShowLoading('');
    $.post('engine/ajax/find_relates.php', { title: title, mode: 1 }, function(data){
      HideLoading('');
      $('#related_news').html(data);
    });
    return false;
  };

to the next one:
function find_relates ( )
  {		
    return false;
  };

Replace the block (line 54)
if(document.addnews.title.value == ''){ 			Growl.info({
        title: '{$lang[p_info]}',
        text: '{$lang['addnews_alert']}'
      }); return false; }
    else{
        dd=window.open('','prv','height=400,width=750,resizable=1,scrollbars=1')
        document.addnews.mod.value='preview';document.addnews.target='prv'
        document.addnews.submit();dd.focus()
        setTimeout(\"document.addnews.mod.value='addnews';document.addnews.target='_self'\",500)
    }

On that:
dd=window.open('','prv','height=400,width=750,resizable=1,scrollbars=1')
        document.addnews.mod.value='preview';document.addnews.target='prv'
        document.addnews.submit();dd.focus()
        setTimeout(\"document.addnews.mod.value='addnews';document.addnews.target='_self'\",500)

Block:
function find_relates ( )
  {
    var title = document.getElementById('title').value;
    ShowLoading('');
    $.post('engine/ajax/find_relates.php', { title: title }, function(data){
      HideLoading('');
      $('#related_news').html(data);
    });
    return false;
  };

We replace with:
function find_relates ( )
  {
    return false;
  };

We remove this:
if(document.addnews.title.value == ''){
      Growl.info({
        title: '{$lang[p_info]}',
        text: '{$lang['addnews_alert']}'
      });
      status = 'fail';
    }

Delete:
if( trim( $title ) == "") {
    msg( "error", $lang['addnews_error'], $lang['addnews_alert'], "javascript:history.go(-1)" );
  }

Replace:
if(document.addnews.title.value == ''){ Growl.info({
        title: '{$lang[p_info]}',
        text: '{$lang['addnews_alert']}'
      }); return false; }
    else{
        dd=window.open('','prv','height=400,width=750,left=0,top=0,resizable=1,scrollbars=1')
        document.addnews.mod.value='preview';document.addnews.target='prv'
        document.addnews.submit();dd.focus()
        setTimeout(\"document.addnews.mod.value='editnews';document.addnews.target='_self'\",500)
    }

On the
dd=window.open('','prv','height=400,width=750,left=0,top=0,resizable=1,scrollbars=1')
        document.addnews.mod.value='preview';document.addnews.target='prv'
        document.addnews.submit();dd.focus()
        setTimeout(\"document.addnews.mod.value='editnews';document.addnews.target='_self'\",500)

We replace
function find_relates ()
  {
    var title = document.getElementById('title').value;
    ShowLoading('');
    $.post('engine/ajax/find_relates.php', { title: title, id: '{$row['id']}' }, function(data){
      HideLoading('');
      $('#related_news').html(data);
    });
    return false;
  };

On the:
function find_relates ()
  {
    return false;
  };

Delete:
if(document.addnews.title.value == ''){

      Growl.info({
        title: '{$lang[p_info]}',
        text: '{$lang['addnews_alert']}'
      });

      status = 'fail';

    }

Delete the line:
if( trim( $title ) == "" and $ifdelete != "yes" ) msg( "error", $lang['cat_error'], $lang['addnews_alert'], "javascript:history.go(-1)" );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question