Help Xin hướng dẫn custom field by waindgo

kamchatka

MasterCorporal
Tham gia
14/04/2015
Bài viết
248
Được Like
162
Tình hình là em mần cái custom field by waindgo hơn 1 tuần nay đủ kiểu nhưng vẫn không có thông . mà bên trong vnxf nhìu cmnt kiu hướng dẫn mà ko thấy hùi âm.
túm tắt lại : xin hướng dẫn làm sao để hiện hình ảnh trên custom field by waindgo , mình làm mà nó chỉ hiện link xin cám ơn .
link đây ạ , mấy bạn xem dùm mình với hix
http://thuvienbode.com/ma-men-nhap-xac-thich-tri-hue.t883.html/
 
  • Like
Reactions: THB

CNTT01

Snow Flower ✔
Tham gia
06/07/2015
Bài viết
803
Được Like
686
Của bạn đây:

This guide will show you how to use the PHP callbacks options with the Custom Fields by Waindigo add-on.


Using the PHP callback field type

Using the PHP callback field type you can create almost any type of field you want.

There are a number of custom fields available as resources which use the PHP callback field type:
Star Rating For Custom Fields 1.1.x by Waindigo
Date Field For Custom Fields by Waindigo


Step 1
Firstly, download and install the latest version of the Custom Fields by Waindigo add-on.

If you are creating a post field, you will also need to install the Custom Post Fields by Waindigo add-on.

If you are creating a social forum field, you will also need to install the Social Groups by Waindigo add-on.

If you are creating a resource field, you will also need to buy and install the XenForo Resource Manager add-on.

Instructions for installing the add-ons can be found on the resource pages.

Step 2
Enable debug mode by adding the following line of code to the bottom of your library/config.php file.
Mã:
$config['debug'] = true;

Step 3 (Thread fields)
To create a custom thread field, from the Admin Control Panel, go to the Applications tab and click Custom Thread Fields.

View attachment 6550

Step 3 (Social forum fields)
To create a custom social forum field, from the Admin Control Panel, go to the Applications tab and click Custom Social Forum Fields.

View attachment 6551

Step 3 (Resource fields)
To create a custom resource field, from the Admin Control Panel, go to the Applications tab and click Resource Fields/Custom Resource Fields (depending on version of Resource Manager installed).

View attachment 6552

Step 3 (Post fields)
To create a custom post field, from the Admin Control Panel, go to the Applications tab and click Custom Post Fields.

View attachment 6553

Step 4
Click the '+ Create New Field' button.

View attachment 6554

Step 5
Browse to the /library folder of your XenForo installation. If this is the first time you have created any PHP callbacks or an add-on, create a new folder to store all your callbacks and add-ons. For this example, we will call the folder Waindigo. The folder name should contain only upper and lowercase characters, and it is recommended that the first letter is a capital letter.

Now create another folder inside the one you just created to identify this callback. For this example, we will call the folder CustomUsernameField. Again, the folder name should contain only upper and lowercase characters, and it is recommended that the first letter is a capital letter.

Step 6
Create an empty .php file inside this folder. For this example, we will call the file CustomField.php, but you can call it anything you like, provided it only contains upper and lowercase characters as before, and it is recommended that the first letter is a capital letter again.

So, we have a new file with a name that is something like:
/library/Waindigo/CustomUsernameField/CustomField.php

If we strip off the /library/ and .php bits and replace the forward slashes with underscores, we get our class name.

For this example, our class name is, therefore:
Waindigo_CustomUsernameField_CustomField

So that XenForo recognises our file, we write our class name in the file as follows:
Mã:
<?php

class Waindigo_CustomUsernameField_CustomField
{

}

Step 7
We now need to add our method. The PHP callback field type has the following callback signature:
Mã:
XenForo_Template_Abstract $template, array $field

We place our method inside of the two braces in our PHP file. Our PHP file will therefore look as follows:
Mã:
<?php

class Waindigo_CustomUsernameField_CustomField
{

    public static function render(XenForo_Template_Abstract $template, array $field)
    {

    }
}

Step 8
Our render function will contain a link to a XenForo template. We will also be able to make available to the template any additional parameters that we want to set.

For our example, we will just provide the template with a parameter called {$field}, which comes from our callback signature and contains all the information about the custom field (such as the ID, title, description, etc.).

The code to create an array of our parameters in our example is as follows:
Mã:
$params = array(
    'field' => $field
);

In the next step, we will create a template called waindigo_username_field_customusernamefield. You will note that we have prepended the template name with the name of our general add-ons folder and appended the template name with the name of our callback folder. Also, template names should only contain lowercase characters and underscores.

The code to link back to the XenForo template is as follows:
Mã:
return $template->create('waindigo_username_field_customusernamefield', $params);

So our PHP file should look like this:
Mã:
<?php

class Waindigo_CustomUsernameField_CustomField
{

    public static function render(XenForo_Template_Abstract $template, array $field)
    {
        $params = array(
            'field' => $field
        );
        return $template->create('waindigo_username_field_customusernamefield', $params);
    }
}

Step 9
Enter the class and method name of the PHP callback into the custom field edit screen and click 'Save Field'.
View attachment 6555

Step 10
To create a new Template, go to the Appearance tab, click Templates and click '+ Create New Template'.
View attachment 6556

Step 11
Name the template waindigo_username_field_customusernamefield and enter the following HTML:
Mã:
<dl class="ctrlUnit">
    <dt>
        <label for="ctrl_{$field.validator_name}">{$field.title}:</label>
        <xen:if is="{$field.required}"><dfn>{xen:phrase required}</dfn></xen:if>
    </dt>
    <dd>
        <input type="search" name="{$field.name}" placeholder="{xen:phrase user_name}..." results="0" class="textCtrl AutoComplete AcSingle" id="ctrl_{$field.validator_name}" />
        <xen:if is="{$field.description}"><p class="explain">{$field.description}</p></xen:if>
    </dd>
</dl>

Step 12
To create a new Admin Template, go to the Development tab, click Admin Templates and click '+ Create Admin Template'.
View attachment 6557

Step 13
Name the template waindigo_username_field_customusernamefield and enter the following HTML:
Mã:
<xen:textbox name="criteria[username]" />
<xen:textbox name="criteria[username]" />

<xen:textboxunit
    inputclass="quickSearchText AutoComplete AcSingle" placeholder="{xen:phrase user_name}..." type="search" results="0" label="{$field.title}:" explain="{xen:raw $field.description}"
    name="{$field.validator_name}" id="ctrl_{$field.validator_name}"
    value="{$field.field_value}" data-validatorname="{$field.validator_name}" />

Done!
 

kamchatka

MasterCorporal
Tham gia
14/04/2015
Bài viết
248
Được Like
162
haizzz cái này đã đọc rồi hình như của lão @THB thì phải , ngâm cả tuần mà ko đc dù sao đi nữa cũng thank lão @CNTT01 .
 
  • Like
Reactions: THB

2L.Ohayo

Moderator
Thành viên BQT
Tham gia
08/03/2015
Bài viết
761
Được Like
835
Ý bác muốn tạo 1 field ở phần đăng chủ đề để điền link ảnh vào đó, khi hiển thị ở thread view thì sẽ hiển thị hình ảnh hả?
 

kamchatka

MasterCorporal
Tham gia
14/04/2015
Bài viết
248
Được Like
162
bác @2L.Ohayo nói chuẩn lun , giống bên site truyện của bác cái " class storyinfo " ấy . đặc thù của 4rum mình gần giống bên bác nên chôm ideal hơi nhìu .
p:/s : nếu đc bác help dùm với thank trước
 

2L.Ohayo

Moderator
Thành viên BQT
Tham gia
08/03/2015
Bài viết
761
Được Like
835
Bác tạo 1 field bình thường, trong tab General options phần Value display điền đoạn sau vào là được
Mã:
<img src="{$value}" alt="Đọc truyện online" height="210" width="170" />
Xin lỗi em chưa tìm được cách lấy title làm alt :))) Css thì bác tự sửa nhé
 

2L.Ohayo

Moderator
Thành viên BQT
Tham gia
08/03/2015
Bài viết
761
Được Like
835
à ở tab Options for text field, nên chọn value match requirements là URL
 

kamchatka

MasterCorporal
Tham gia
14/04/2015
Bài viết
248
Được Like
162
đã chọn rồi lão @2L.Ohayo vẫn không được nó chỉ hiện cái link mà ko hiện ra hình ảnh chẳng bik sao lun
 

kamchatka

MasterCorporal
Tham gia
14/04/2015
Bài viết
248
Được Like
162
okie goy thank lão để mai ngâm cứu thêm field nữa
 

vuvanthuong91

Private
Tham gia
16/10/2015
Bài viết
1
Được Like
0
các bạn cho hỏi mình muốn đưa cái field đó ra portal thì phải làm thế nào ạ, xin hậu tạ bạn nào giúp mình
Thân!
 

Hướng dẫn sử dụng

XenForo 1 XenForo 2
Translate by PVS

Dịch vụ XenForo của VNXF

Mobile/Zalo: 0906081284

Telegram: anhanhxf

Chỉ nhận web nội dung lành mạnh

Nhà Tài Trợ

Mút Xốp Không Gian
Mút Sofa Không Gian
Top Bottom