PHP code example of fostercommerce / entry-type-rules

1. Go to this page and download the library: Download fostercommerce/entry-type-rules library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fostercommerce / entry-type-rules example snippets




return [
    'sections' => [
        
        // Ex. A 'Pages' structure section handle we want to set rules for entry types in it
        'pages' => [

            // Ex. A 'Contact Page' entry type handle with rules set to limit it to 1 entry
            'contactPage' => [
                'limit' => 1,
            ],

            // Ex. A 'Blog Landing' entry type handle with rules set to limit it to 1 entry,
            // and only allow the 'Site Admins' user group to create new ones
            'blogLanding' => [
                'limit' => 1,
                'userGroups' => ['siteAdmins']
            ],

        ],
        
        // Ex. A 'Blog' channel section handle we want to set rules for entry types in it
        'blog' => [
        
            // Ex. A 'Press Releases' entry type handle with rules to only allow the 'Content Editors'
            // and 'Content Providers' user groups to create new ones for
            'pressRelease' => [
                'userGroups' => [
                    'contentEditors',
                    'contentProviders',
                ]
            ],

        ]
      
    ]
];