PHP code example of jjkkopq / configx

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

    

jjkkopq / configx example snippets


    'extensions' => [
        'configx' => [
            // Set to `false` if you want to disable this extension
            'enable' => true,
            'tabs' => [
                'base' => '基本设置',
                'shop' => '店铺设置',
                'uplaod' => '上传设置',
                'image' => '' // if tab name is empty, get from trans : trans('admin.configx.tabs.image'); tab名称留空则从翻译中获取
            ],
            // Whether check group permissions. 
            //if (!Admin::user()->can('confix.tab.base')) {/*hide base tab*/ } .
            'check_permission' => false
        ],
    ],


/*
|-------------------------------------------------------------------------------------
|  r_label\ c_labe |       c_label1      |        c_label2     |      c_label3       |  ⬅Col labels
|-------------------------------------------------------------------------------------
|     r_label1     |  base.some_key_1_1  |  base.some_key_1_2  |  base.some_key_1_3  |
|-------------------------------------------------------------------------------------
|     r_label2     |  base.some_key_2_1  |  base.some_key_2_2  |  base.some_key_2_3  |
|-------------------------------------------------------------------------------------
|     r_label3     |  base.some_key_3_1  |  base.some_key_3_2  |  base.some_key_3_3  |
|-------------------------------------------------------------------------------------
        ↑
    Row labels

You can edit labels as you want.

Each <td> has a key , base.some_key_[0]_[0] to base.some_key_[rows-1]_[cols-1] . (from 0 to length -1 )

So, you can chang a label <td> to input :

|-------------------------------------------------------------------------------------
|  r_label\ c_labe |       c_label1      |        c_label2     |  base.some_key_0_3  |  ⬅ [c_label3] change to [base.some_key_0_3]
|-------------------------------------------------------------------------------------     , we can input here .
|     r_label1     |  base.some_key_1_1  |  base.some_key_1_2  |  base.some_key_1_3  |      (可以把label 换成输入元素)
|-------------------------------------------------------------------------------------
|     r_label2     |  base.some_key_2_1  |  base.some_key_2_2  |  base.some_key_2_3  |
|-------------------------------------------------------------------------------------
| trans.sometext   |  base.some_key_3_1  |     hello world!    |  base.some_key_3_3  |
|-------------------------------------------------------------------------------------
          ↑                                           ↑
          ↑                           [base.some_key_3_2] change to [hello world!]
          ↑                              , we can not input here any more ,
          ↑                           it wiil just show label text 'hello world!' .
          ↑                              (也可以把输入元素换成仅显示文字)
          ↑
  get text from trans
trans("admin.configx.base.some_key.sometext")
显示文字时可以从翻译获取文字,样式 `trans.sometext`
其中 sometext 为翻译的key



note : if text = key or text = '' ,render as input form element , otherwise just show the text you leave.

//if text is trans.sometext , get from trans : trans("admin.configx.{$tab}.{$tablekey}.{$sometext}")

总结 : 如果输入的字符串与td默认key一样或输入的字符串为空,这个位置将是一个可输入的表单元素,否则就显示原样你输入的字符串 .


*/
Add a lang config in `resources/lang/{zh-CN}/admin.php`