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!

  1. Open include/functions_validate.php
    Add before the closing
    ?>
    this 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;
    }
    
  2. 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}
    
  3. Open submit.php
    Find
    SmartyValidate :: register_criteria('isBannedEmail'    , 'validate_is_banned_email', 'submit_link');
    
    Replace with
    SmartyValidate :: register_criteria('isBannedEmail'    , 'validate_is_banned_email', 'submit_link');
    SmartyValidate :: register_criteria('isNotTop'         , 'validate_not_top'        , 'submit_link');
    
    Find
    SmartyValidate :: register_validator('v_CATEGORY_ID'   , 'CATEGORY_ID:0'      , 'isNotEqual', false, false, null, 'submit_link');
    
    Replace with
    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');
    
  4. Open your template's category_select.tpl
    Find (you should do the replacement for all 3 instances you find)
    {validate form="submit_link" id="v_CATEGORY_ID" message=$smarty.capture.no_url_in_top}
    
    Replace with
    {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}
    

Official help on our support forum

Back to the Mods collection