PHP code example of madebyprisma / better-link

1. Go to this page and download the library: Download madebyprisma/better-link 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/ */

    

madebyprisma / better-link example snippets




use MadeByPrisma\BetterLink\BetterLink;
use MadeByPrisma\BetterLink\BetterLinkField;

class YourPage extends Page {
	private static $has_one = [
		"YourLink" => BetterLink::class
	];

	private static $owns = [
		"YourLink"
	];

	public function getCMSFields() {
		$fields = parent::getCMSFields();
		
		$fields->addFieldsToTab("Root.Main", [
			new BetterLinkField("YourLink", "Your Link")
		]);

		return $fields;
	}
}