Hi there,
I’m trying to implement some A/B testing in my Front Page template using Sage 9 & Sober WP controller (which rocks btw!) and I was wondering if it’s possible to pass a page ID in order to render a Blade partial with the content from that ID?
For example, in my resources/views/front-page.blade.php
:
@section('content')
@while(have_posts()) @php(the_post())
@if ($ab_testing->curVariation === $ab_testing->variationKey)
<section id="ab-test">
<?= \App\template('partials.content-page', ['id' => $ab_testing->$id]); ?>
</section>
@endif
@php($ab_testing->optimizely->track($ab_testing->eventKey, $ab_testing->userId))
@endwhile
@endsection
In my partials/content-page.blade.php
:
@include('blocks.b-page-header', array(
'title' => App::title($id),
'tagline' => $page_fields($id)->tagline,
'image' => $page_fields($id)->image,
'subtitle' => $page_fields($id)->subtitle
))
@include('blocks.b-modules', array(
'modules' => $page_fields($id)->modules
))
I want to get data from my app/controllers/Page.php
controller:
namespace App\Controllers;
use Sober\Controller\Controller;
use AcfFields;
class Page extends Controller {
public function PageFields($id = null) {
return json_decode(json_encode([
'tagline' => AcfFields::getField('page_tagline', $id),
'subtitle' => AcfFields::getField('page_subtitle', $id),
'image' => get_post_thumbnail_id($id),
'modules' => AcfFields::getField('page_modules', $id)
]));
}
}
But I don’t think it’s possible like this? I get an error:
Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Function name must be a string
Is it possible to somehow pass function parameters to the Controller class functions?
Thanks!