PHP code example of jonasholfeld / kirby3-many-to-many-field

1. Go to this page and download the library: Download jonasholfeld/kirby3-many-to-many-field 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/ */

    

jonasholfeld / kirby3-many-to-many-field example snippets


<h1>Projects</h1>

// using the `toStructure()` method, we create a structure collection from the manytomany-field
$projects = $page->projects()->toStructure();
// we can then loop through the entries and render the individual fields
foreach($projects as $project):
    // Fetching the project page by using the page method
    $projectPage = kirby()->page($project->foreignkey());