PHP code example of chameleon2die4 / sage9-components

1. Go to this page and download the library: Download chameleon2die4/sage9-components 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/ */

    

chameleon2die4 / sage9-components example snippets


add_filter('sober/components/namespace', function () {
    return 'Data\Partials';
});



namespace App\Controllers\Components;

use Chameleon2die4\Components\Component;

class Slider extends Component
{
    /**
     * Return images from Advanced Custom Fields
     *
     * @return array
     */
    public function images()
    {
        return get_field('images');
    }
}

@if($images)
  <ul>
    @foreach($images as $image)
      <li><img src="{{$image['sizes']['thumbnail']}}" alt="{{$image['alt']}}"></li>
    @endforeach
  </ul>
@endif
 
@

@extends('layouts.app')

@section('content')
  @while(have_posts()) @php the_post() @endphp
    @

public function __before()
{
    // runs after this->data is set up, but before the class methods are run
}

public function __after()
{
    // runs after all the class methods have run
}