Custom Fields

Custom fields for you CMS Pages, RainLab.Blog and Rainlab.User

Back to Custom Fields Support

hellopaint
hellopaint

How can I search one variable in a where query? Thanks in advance.

Last updated

Vladimir
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

hellopaint
hellopaint

Ok Vladimir, thanks but I extended user variables without Plugin finally.

1-3 of 3