← Back to Custom Fields Support
Vladimir
It is not possible to get a field by a simple query to the database.
function onEnd() {
//fist way
$component = $this->page->components['blogPost'];
dump($component->post->getField('preview'));
//other way
$name = 'preview'; //field name
$post_id= 3; //post id
$tabIndexs = Pkurg\Customfields\Models\TabOrder::where('tabname', '!=', '')->pluck('id');
$model = RainLab\Blog\Models\Post::find($post_id);
foreach ($tabIndexs as $i) {
$index = 'value' . $i;
if ($model->blog->$index) {
foreach ($model->blog->$index as $key => $value) {
if (array_key_exists($name, $value)) {
foreach ($model->blog->$index as $key => $value) {
if (array_key_exists($name, $value)) {
dump($value[$name]);
}
}
}
}
}
}
}
Last updated
1-3 of 3