This mod simply disallows all submissions to top level categories. Works for phpLD 3.2 & 3.3.
A more complex version, fully configurable from the admin that allows/disallows links by type is available in the free phpLD Expansion Pack
Important: backup all files before modifying them!
- Open include/functions_validate.php
Add before the closingthis code?>
/** * [mod] No submissions to top categories * Author: Paul Martin (www.phpldaddons.com) */ function validate_not_top($value, $empty, &$params, &$formvars) { global $db; global $tables; $valid = 1; $cdata = $db->GetRow("SELECT * FROM `{$tables['category']['name']}` WHERE `ID`=$value"); if (0 == $cdata['PARENT_ID']) $valid = 0; unset($cdata); return $valid; } - Open templates/Core/messages.tpl
Add anywhere you feel like (code should be entered as one line){capture name='no_url_in_maintop'}<span class="errForm">Links cannot be submitted to top categories. Please choose a suitable subcategory.</span>{/capture} - Open submit.php
FindReplace withSmartyValidate :: register_criteria('isBannedEmail' , 'validate_is_banned_email', 'submit_link');FindSmartyValidate :: register_criteria('isBannedEmail' , 'validate_is_banned_email', 'submit_link'); SmartyValidate :: register_criteria('isNotTop' , 'validate_not_top' , 'submit_link');Replace withSmartyValidate :: register_validator('v_CATEGORY_ID' , 'CATEGORY_ID:0' , 'isNotEqual', false, false, null, 'submit_link');SmartyValidate :: register_validator('v_CATEGORY_ID' , 'CATEGORY_ID:0' , 'isNotEqual', false, false, null, 'submit_link'); SmartyValidate :: register_validator('v_CATEGORY_TOP' , 'CATEGORY_ID' , 'isNotTop' , false, false, null, 'submit_link'); - Open your template's category_select.tpl
Find (you should do the replacement for all 3 instances you find)Replace with{validate form="submit_link" id="v_CATEGORY_ID" message=$smarty.capture.no_url_in_top}{validate form="submit_link" id="v_CATEGORY_ID" message=$smarty.capture.no_url_in_top} {validate form="submit_link" id="v_CATEGORY_TOP" message=$smarty.capture.no_url_in_maintop}









