[MOD] Disable contact form in sNews

Comments (2)

sNews

This is an update/fix for the "Enable/Disable Contact Form via Admin Panel" mod posted by sNews3M here. This mod will allow you to disable the contact form via an option in the contact settings of sNews admin page.

In its previous state the mod only turns the contact form into a blank page with no way of reversing the change from the settings. My update attempts to improve this by disabling menu links, disabling the contact page url and fix the setting to allow the form to be enabled after being disabled. Hopefully this guide with extra detail will also help less experienced users. Please note that you should not create any pages using the "contact" url after this mod or you will get a blank page as before.

Backup first!

Be sure to backup all files and your database before proceeding. The following modification is performed at your own risk.

Changing the code

This first step involving your database is highly dependent upon your own setup, so please read all of it first to find which applies to you.

Default sNews with no prefix

Go to your MySQL admin page and insert the following into your sNews table (updated code):

INSERT INTO   `settings` VALUES  ('', 'contact_off', 'NO');

Default sNews with table prefix

If you are using a table prefix you need to enter it in place of the highlighted text and insert the following code to your database (updated code):

INSERT INTO   `prefix_settings` VALUES  ('', 'contact_off', 'NO');

Add variable to language file

Add the following to the bottom of your language file (updated code):

	# [MOD] ENABLE/DISABLE CONTACT FORM
	$l['contact_off'] = 'Disable contact form (Disables the contact form and all links to it, "/contact" will return 404.';

Edit snews.php

Find and replace the following blocks of code.

Find:

	$class = ($categorySEF == 'contact') ? ' class="current"': '';
	echo '<li><a'.$class.' href="'._SITE.'contact/">'.l('contact').'</a></li>';

Replace with (updated code):

	# [MOD] ENABLE/DISABLE CONTACT FORM
	if(s('contact_off') == 'NO') {
		$class = ($categorySEF == 'contact') ? ' class="current"': '';
		echo '<li><a'.$class.' href="'._SITE.'contact/">'.l('contact').'</a></li>';
	}
	# END [MOD] ENABLE/DISABLE CONTACT FORM

Find:

// CONTACT FORM
function contact() {
 	if (!isset($_POST['contactform'])) {

Replace with:

// CONTACT FORM
function contact() {
	# [MOD] ENABLE/DISABLE CONTACT FORM
	if(s('contact_off') == 'YES') return;
	# END [MOD] ENABLE/DISABLE CONTACT FORM
 	if (!isset($_POST['contactform'])) {

Find:

	echo html_input('text', 'contact_subject', 'cs', s('contact_subject'), l('a_contact_subject'), '', '', '', '', '', '', '', '', '', '');
	echo '</div></fieldset></div><div class="adminpanel">';

Replace with (updated code):

	echo html_input('text', 'contact_subject', 'cs', s('contact_subject'), l('a_contact_subject'), '', '', '', '', '', '', '', '', '', '');
	# [MOD] ENABLE/DISABLE CONTACT FORM
	echo html_input('checkbox', 'contact_off', 'co', s('contact_off'), l('contact_off'), '', '', '', '', (s('contact_off') == 'YES' ? 'ok' : ''), '', '', '', '', '');
	# END [MOD] ENABLE/DISABLE CONTACT FORM
	echo '</div></fieldset></div><div class="adminpanel">';

Find:

				$allowed_img = $_POST['allowed_img'];
				$ufield = array(

Replace with:

				$allowed_img = $_POST['allowed_img'];
				# [MOD] ENABLE/DISABLE CONTACT FORM
				$contact_off = $_POST['contact_off'] == 'on' ? 'YES' : 'NO';
				# END [MOD] ENABLE/DISABLE CONTACT FORM
				$ufield = array(

Find:

					'allowed_images' => $allowed_img

Replace with:

					'allowed_images' => $allowed_img,
					# [MOD] ENABLE/DISABLE CONTACT FORM
					'contact_off' => $contact_off
					# END [MOD] ENABLE/DISABLE CONTACT FORM

Find:

//SEF links of the hardcoded items - RESERVED WORDS - will clash if using for article/category seftitles.
		$l['cat_listSEF'] = 'archive,contact,sitemap,login';

Replace with (new code):

//SEF links of the hardcoded items - RESERVED WORDS - will clash if using for article/category seftitles.
		# [MOD] ENABLE/DISABLE CONTACT FORM
		if(s('contact_off') == 'YES') {
			$l['cat_listSEF'] = 'archive,sitemap,login';
			}	else {
				$l['cat_listSEF'] = 'archive,contact,sitemap,login';
				}
		# END [MOD] ENABLE/DISABLE CONTACT FORM

Find:

	echo $link.'contact/">'.l('contact').'</a></li>';

Replace with (new code):

	# [MOD] ENABLE/DISABLE CONTACT FORM
		if(s('contact_off') == 'NO') {
	echo $link.'contact/">'.l('contact').'</a></li>';
	}
	# END [MOD] ENABLE/DISABLE CONTACT FORM

Hopefully thats it working well now. You should now be able to access the new option from "Admin Panel> Settings> Contact Info> Disable contact form". Leave a comment if you have any problems with it.


Comments

Andrew said:
2nd May, 2010 @ 12:28 amAndrew

Hi, I am searching for a simple way to disable 'write a comment' under the articles in sNews, my sites that run the script are heavily spammed. So I thought there might be a way to get rid of this function. Do you know of any link or site where this is explained and guided?


Scott said:
4th Jun, 2010 @ 4:11 pmScott

Sorry for the late reply, I missed the comment.

Feel free to correct me if I am misunderstanding the situation but why don't you simply disable comments altogether? Or freeze them if you don't want to lose comments you already have. Removing the add comment part would make comments the same as if you froze them I believe.

You can disable/freeze comments for individual pages under that pages options when editing it. Doing it for all pages can be done via the main settings in the admin panel.


Write a comment

* = required field

:

:

:

:



Back to top