3

Product support

Get help in the plugin support forum.

Categories

This plugin add custom fields to CMS Pages, RainLab.Blog posts and Rainlab.User

Available field types: text, textarea, checkbox, number, codeeditor, colorpicker, datepicker, taglist, markdown, richeditor, mediafinder

Table of Contents

  1. Rainlab Blog Custom Fields
  2. Cms Page Custom Fields
  3. User Custom Fields
  4. API

1) Rainlab Blog Custom Fields

Video manual

Creating group fields

Go to Custom Fields Create group our cusom field Set Tab caption and target type page

Adding new fields.

Go to the blog post page and make sure that our fields are available.

Using fields

post.getField($name) - get field by name

{{ post.getField('name')}} 
{{ post.getField('customcolor')}} 
{{ post.getField('image') | media }} 
<img src="{{ post.getField('image') | media }}" />

post.getRepeatField - get repeated field by name

{% for item in post.getRepeatField('items') %}

    <p>{{ item }}</p>

{% endfor %}

2) Cms Page Custom Fields

Video manual

Creating group fields

  • Go to Custom Fields.
  • Create group our cusom field.
  • Set Tab caption and target type page.
  • Adding new fields.
  • Go to the CMS page and make sure that our fields are available.

Using fields

Simple {{ viewBag.group_fields_name[0].field_name }} where "firstfields" name of field

{{ viewBag.data[0].richtext | raw  }}
{{ viewBag.data[0].myitem | raw }}
<img src="{{ viewBag.data[0].image | media }} " >

{% for items in viewBag.items %}

    <p style="color:{{ items.itemcolor }}; font-weight: bold;" >{{ items.item }}</p>

{% endfor %}

3) User Custom Fields

Video manual

Creating group fields

  • Go to Custom Fields.
  • Create group our cusom field.
  • Set Tab caption and target type page.
  • Adding new fields.

Using user custom fields

//get custom fields data on frontend
{{ user.getField('first') }}
{{ user.getField('second') }}

//save custom fields data on frontend
//param1 -  group field name, param2 - fields data array
$user->setField('usercustomfields', [[
        "first" => input('first'),
        "second" => input('second'),
        "photo" => input('photo'),
    ]]
    );

Example user cabinet user.htm

title = "user"
url = "/user"
layout = "default"
is_hidden = 0
robot_index = "index"
robot_follow = "follow"

[session]
security = "all"
==
<?php
use RainLab\User\Models\User as UserModel;

function onSave()
{

    $user = UserModel::where('id', input('id'))->first();
    $user->name = input('name');
    $user->email = input('email');
    $user->password = input('password');
    $user->password_confirmation = input('password_confirmation');
    $user->setField('usercustomfields', [[
        "first" => input('first'),
        "second" => input('second'),
        "photo" => input('photo'),
    ]]
    );

    $user->save();

    Flash::success('Successfully saved!');

}
?>
==
<section id="demo" class="section demos bg-gray">
    <div class="container">
        <div class="row">
            <div class="col-sm-12 text-center section-title">
                <br>

                {% if user %}

                <form class="" data-request="onSave" data-request-flash >

                   <input name="id" type="text" class="form-control" id="accountName" value="{{ user.id }}" hidden>

                   <div class="form-group">
                    <label for="accountName">Full Name</label>
                    <input name="name" type="text" class="form-control" id="accountName" value="{{ user.name }}">
                </div>

                <div class="form-group">
                    <label for="accountEmail">Email</label>
                    <input name="email" type="email" class="form-control" id="accountEmail" value="{{ user.email }}">
                </div>

                <div class="form-group">
                    <label for="accountPassword">New Password</label>
                    <input name="password" type="password" class="form-control" id="accountPassword">
                </div>

                <div class="form-group">
                    <label for="accountPasswordConfirm">Confirm New Password</label>
                    <input name="password_confirmation" type="password" class="form-control" id="accountPasswordConfirm">
                </div>

                <div class="form-group">
                    <label for="accountName">First test field</label>
                    <input name="first" type="text" class="form-control" id="accountName" value="{{ user.getField('first') }}">
                </div>

                <div class="form-group">
                    <label for="accountName">Second test field</label>
                    <input name="second" type="text" class="form-control" id="accountName" value="{{ user.getField('second') }}">
                </div>

                <div class="form-group">
                    <label for="accountName">Photo</label>

                    <input name="photo" type="text" class="form-control" id="accountName" value="{{ user.getField('photo') }}">

                    <img style="width: 200px" class="form-control" src="{{ user.getField('photo') | media }}">

                </div>

                <button type="submit" class="btn btn-default">Save</button>
            </form>

            <p>Hello {{ user.name }}</p>

            {% else %}
            <p>Nobody is logged in</p>
            {% endif %}

        </div>
    </div>
</div>
</section>

4) API

Get API key

Settings->Custom Fields->API KEY

List of field groups

GET|HEAD | api/v1/fields/list

URL: GET http://oct.pkurg.ru/api/v1/fields/list?key=5d37221eed8a7

Response:

[
  {
    "id": 3,
    "type": "Blog",
    "name": "wwwwww",
    "custom_fields": [
      {
        "name": "ww",
        "type": "text",
        "caption": "ww",
        "comment": "wwww"
      }
    ],
    "caption": "New Tabwww",
    "created_at": "2019-07-23 06:19:23",
    "updated_at": "2019-07-23 06:19:23"
  },
  {
    "id": 6,
    "type": "Blog",
.................. and more

Show by field group id

GET|HEAD | api/v1/fields/{field}

URL: GET http://oct.pkurg.ru/api/v1/fields/5?key=5d37221eed8a7

Response:

{
  "id": 5,
  "type": "Blog",
  "name": "files",
  "custom_fields": [
    {
      "name": "mark",
      "type": "markdown",
      "caption": "My mark",
      "comment": "comment"
    }
  ],
  "caption": "Test New Tab",
  "created_at": "2019-07-23 07:47:48",
  "updated_at": "2019-07-23 07:47:48"
}

Create new fields group

possible types:

  • CMS Page
  • Blog
  • User

POST | api/v1/fields

URL: POST http://oct.pkurg.ru/api/v1/fields?key=5d37221eed8a7

Payload:

{  
  "type": "Blog",
  "name": "filwesqqq",
  "custom_fields": [
    {
      "name": "mark",
      "type": "markdown",
      "caption": "My mark",
      "comment": "comment"
    }
  ],
  "caption": "Test New Tab 2"
}

Response:

'ok saved'

Delete fields group

DELETE | api/v1/fields/{field}

URL: DELETE http://oct.pkurg.ru/api/v1/fields/2?key=5d37221eed8a7

Response:

'ok deleted'
  • Found the plugin useful on 28 Sep, 2019

    The support for this plugin is amazing! Author responds and provides solutions almost instantly. Can't wait to see what features will be added in the future.

  • Found the plugin useful on 11 Jul, 2019

    This great plugin can expand your blog and CMS page in two clicks. This plugin can make a full-featured catalog from a blog. Everything works and everything is clear. Wish. Make it possible to manage the sequence of tabs.

2.1.8

fix

Oct 17, 2019

2.1.7

small fix

Oct 15, 2019

2.1.6

Updated table pkurg_customfields_fields

Sep 28, 2019

2.1.5

CMS Page select fix

Sep 22, 2019

2.1.4

Adds User custom fields

Sep 21, 2019

2.1.3

Created table pkurg_customfields_usertabvalueorder

Sep 21, 2019

2.1.2

Created table pkurg_customfields_users_data

Sep 21, 2019

2.1.1

Updated table pkurg_customfields_value_data

Sep 21, 2019

2.1.0

fix

Sep 21, 2019

2.0.9

Updated table pkurg_customfields_fields

Sep 20, 2019

2.0.8

Updated table pkurg_customfields_value_data

Sep 20, 2019

2.0.7

fix

Sep 20, 2019

2.0.6

Fixed permissions for settings

Jul 29, 2019

2.0.5

Fix

Jul 25, 2019

2.0.4

Add API

Jul 23, 2019

2.0.3

Add user permissions

Jul 10, 2019

2.0.2

Small update

Jun 11, 2019

2.0.1

Small update

Jun 11, 2019

2.0.0

Second version

Jun 11, 2019

1.0.6

Created table pkurg_customfields_tabvalueorder

Jun 11, 2019

1.0.5

Updated table pkurg_customfields_value_data

Jun 11, 2019

1.0.4

Updated table pkurg_customfields_value_data

Jun 11, 2019

1.0.3

Created table pkurg_customfields_fields

Jun 09, 2019

1.0.2

Created table pkurg_customfields_value_data

Jun 09, 2019

1.0.1

Initialize plugin.

Jun 09, 2019