Phpcms How to use the PHP method for universal Fields

Source: Internet
Author: User

From: http://www.tantengvip.com/2013/12/phpcms-php-function/

Phpcms Background Content Module---Model Management--add field function is very powerful, you only need to operate in the PHPCMS background panel, do not have to manually build tables in the database, do not operate the database to add or delete fields, added the fields and types, publish content, The fields and types you want are automatically displayed on the form, which makes it a lot easier, including forms validation, sorting, and so on.

Phpcms also provides a field called the Universal field, where the user can customize more functions of the field.

To set up a custom form:

<input type= ' text ' name= ' info[game_swf] ' value= ' {FUNC (Show_date~~{field_value})} ' >

For example, there is a text box, I need to fill out the form, the box in the default display a path,/yx/swf/201312/, and then manually fill in the following content, so can only select the Phpcms in the Universal field, but value cannot write {php ...} Such a form, also can not use <?php ...? > Grammar, it will filter out for you.

This time to use the PHPCMS provides a way to call the function, the syntax is {FUNC (function~~params)}, so you can invoke the custom Php method, function is the name of the functions, two ~ ~ followed by parameters.

For example, I added a function in the phpcms extension function file extension.func.php:

/*/function show_date ($field)    {if(' = =$ Field) {        return '/yx/swf/'.  Date("Ym"). ' /';    } Else {        return$field;    }}

Its function is to pass in the form's value, {Field_value}, and if it is empty, display '/yx/swf/'. Date ("Ym"). ' /', otherwise the edit is displayed as is. This solves the problem.

This is where the almighty field is all about.

Phpcms How to use PHP methods for universal fields

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.