PHP code example of visuellverstehen / statamic-content-renderer

1. Go to this page and download the library: Download visuellverstehen/statamic-content-renderer 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/ */

    

visuellverstehen / statamic-content-renderer example snippets


use VV\ContentRenderer\Renderer;

// ...

$renderer = new Renderer();
$renderer->setContent($entry, 'my_replicator_field');
$renderer->setView('sets');

$content = $renderer->render();

namespace App\SearchTransformers;

use VV\ContentRenderer\Renderer;
 
class MyReplicatorFieldTransformer
{
    public function handle($value, $field, $searchable)
    {
        $renderer = new Renderer();
        $renderer->setContent($searchable, 'my_replicator_field');
        $renderer->setView('sets');
        
        return $renderer->render();
    }
}

$renderer = (new Renderer())->$withLinkTargets();

// read more <a href="https://visuellverstehen.de">about the author</a> of this package
// becomes: read more about the author (https://visuellverstehen.de) of this package

$renderer = (new Renderer())->withHtmlTags();

$renderer = new Renderer();
$renderer->setContent($searchable, 'bard_content');
// …

$renderer->process(function ($content) {
    // modify content
    
    return $content;
});