Require choose at least a category before post news » DataLife Engine Support

DLEVIET - DataLife Engine Support Home Page

DataLife Engine Support » DataLife Engine » Edit Code » Require choose at least a category before post news

Require choose at least a category before post news

  • Author: admin;  
  • Views: 3095;  
  • Date: 27 April 2009;  
Require choose at least a category before post news


I tired of the fact that many users forget to specify the category when add news in my site. Therefore I made to the code a couple of extra lines to remind the user of the need to specify a category.

Do IT

Open file engine/modules/addnews.php

Find


        if( $config['allow_site_wysiwyg'] == "yes" ) $script .= "<form method=post name=\"entryform\" id=\"entryform\" onsubmit=\"document.getElementById('short_story').value = tinyMCE.get('short_story').getContent(); document.getElementById('full_story').value = tinyMCE.get('full_story').getContent(); if(document.entryform.title.value == '' || document.entryform.short_story.value == ''){alert('$lang[add_err_7]');return false}\" action=\"\">";
        else $script .= "<form method=post name=\"entryform\" id=\"entryform\" onsubmit=\"if(document.entryform.title.value == '' || document.entryform.short_story.value == ''){alert('$lang[add_err_7]');return false}\" action=\"\">";



Replace to


        $spe_category = ";if(document.entryform.category.value == '') { alert('Vui long chon chuyen muc cua bai viet');;return false } ";
        if( $config['allow_site_wysiwyg'] == "yes" ) $script .= "<form method=post name=\"entryform\" id=\"entryform\" onsubmit=\"document.getElementById('short_story').value = tinyMCE.get('short_story').getContent(); document.getElementById('full_story').value = tinyMCE.get('full_story').getContent(); if(document.entryform.title.value == '' || document.entryform.short_story.value == ''){alert('$lang[add_err_7]');return false}$spe_category\" action=\"\">";
        else $script .= "<form method=post name=\"entryform\" id=\"entryform\" onsubmit=\"if(document.entryform.title.value == '' || document.entryform.short_story.value == ''){alert('$lang[add_err_7]');return false}$spe_category\" action=\"\">";        



----------------------------------------------------
If you want to apply this h@ck in Admin CP, follow steps below

Open file engine/inc/addnews.php
----------------------------------------------------
Find

    if( $config['allow_admin_wysiwyg'] == "yes" ) echo "<form method=post name=\"addnews\" id=\"addnews\" onsubmit=\"document.getElementById('short_story').value = tinyMCE.get('short_story').getContent(); document.getElementById('full_story').value = tinyMCE.get('full_story').getContent(); if(document.addnews.title.value == '' || document.addnews.short_story.value == ''){alert('$lang[addnews_alert]');return false}\" action=\"$PHP_SELF\">";
    else echo "<form method=post name=\"addnews\" id=\"addnews\" onsubmit=\"if(document.addnews.title.value == '' || document.addnews.short_story.value == ''){alert('$lang[addnews_alert]');return false}\" action=\"$PHP_SELF\">";


Replace to

$spe_category = ";if(document.addnews.category.value == '') { alert('Please choose at least a category');;return false } ";

    if( $config['allow_admin_wysiwyg'] == "yes" ) echo "<form method=post name=\"addnews\" id=\"addnews\" onsubmit=\"document.getElementById('short_story').value = tinyMCE.get('short_story').getContent(); document.getElementById('full_story').value = tinyMCE.get('full_story').getContent(); if(document.addnews.title.value == '' || document.addnews.short_story.value == ''){alert('$lang[addnews_alert]');return false}$spe_category\" action=\"$PHP_SELF\">";
    else echo "<form method=post name=\"addnews\" id=\"addnews\" onsubmit=\"if(document.addnews.title.value == '' || document.addnews.short_story.value == ''){alert('$lang[addnews_alert]');return false}$spe_category\" action=\"$PHP_SELF\">";


Source : dleviet.com
We encourage you to Register or Login to website under your name.

Michael

Posted 22 May 2010 22:21 Register: 14.03.2010
anyone tried this

don't try this
this doesn't works
i tried it
and got this error

Parse error: syntax error, unexpected T_ELSE in /homepublic_html/engine/modules/addnews.php on line 497
tried on DLE 8.3

jaganguys

Posted 23 May 2010 20:54 Register: 7.04.2010
hi its working fine..
i am using this..
i tested on both 8.3 & 8.5
check out your errors..

ScriptKing

Posted 30 May 2010 05:09 Register: 17.03.2010
Anyone know how to make it so people need to pick tags aswell?

ScriptKing

Posted 12 August 2010 19:00 Register: 17.03.2010
This works fine for me but i use 8.0 pro its the best looking Admin section i have found test it..

farhanali560

Posted 14 October 2010 16:45 Register: 22.05.2010
Thx My All Friend And Admin Realy This Code Working I am testing this website
wink

mohitshukla

Posted 26 November 2010 18:03 Register: 24.04.2010
Parse error: syntax error, unexpected T_ELSE in /home/futurezd/public_html/engine/modules/addnews.php on line 513



PLz Solve This Error.

admin

Posted 7 December 2010 08:22 Register: 25.04.2009
mohitshukla,

It work, you need to check what you did!

mafia03

Posted 5 February 2011 15:46 Register: 5.02.2011
working 100% at DLE 9.2 :D

simonpeterstp

Posted 20 March 2011 20:16 Register: 26.01.2011
Thanks it works withmy site
Information
Members of Guest cannot leave comments.

Pagerank Update

    Updates Yandex SEO
    13.04.2012
    16.02.2012
    04.02.2012
    Updates Yandex search
    17.05.2012
    15.05.2012
    12.05.2012
    Updates Yandex Catalogue
    18.05.2012
    16.05.2012
    11.05.2012
    Updates Google
    03.05.2012
    06.02.2012
    08.11.2011

Find us on Facebook

Poll

How do you know DataLife Engine Support?

Search Engine
Other DLE Support websites
Forum
Friends
Others

Sponsor

Calendar

«    May 2012    »
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
Contact us in social network

Facebook

Twitter