小编Rif*_*arr的帖子

如何在视图Yii中调用模型函数?

我在模型Yii中有一个公共函数:

public function test() {
    echo 'I am working';
}
Run Code Online (Sandbox Code Playgroud)

现在我想在视图Yii上调用此函数.我喜欢通过控制器而不是在视图Yii上直接调用该函数.

那么如何在视图Yii上调用该函数呢?在我在Yii上调用它之前我和控制器有什么关系?

php yii

2
推荐指数
1
解决办法
7923
查看次数

为什么我不能将wordpress函数分配给变量?

我正在创建一个表单,将表单的详细信息发送到我的电子邮件.这是我的代码:

<?PHP
$errors = array();
if (isset($_POST["submit"])) {
    $to = "myemail@email.com";
    $subject = "This is my subject";    
    $hotel = echo get_permalink();
    $headers = array('From: '.$_POST['sendername'].' <'.$_POST['senderEmail'].'>');
    //Check the name and make sure that it isn't a blank/empty string.
        if(empty($sender)){
            //Blank string, add error to $errors array.        
            $errors['sendername'] = "Please enter your name!";
        }
        if(empty($senderEmail)){
            //Blank string, add error to $errors array.        
            $errors['senderEmail'] = "Please enter your email!";
        }
    $mailBody = "<h3>Hotel Details</h3>"

    $mail_sent = wp_mail( $to, $subject, $mailBody, $headers ); …
Run Code Online (Sandbox Code Playgroud)

php forms email wordpress

2
推荐指数
1
解决办法
195
查看次数

如何保存元框值?

我创建了一个元框。代码是:

// Create your custom meta box
add_action( 'add_meta_boxes', 'hotel_amenities' );
   // Add a custom meta box to a post
    function hotel_amenities( $post ) { 
        add_meta_box(
                'Meta Box Amenities', // ID, should be a string
                'Amenities', // Meta Box Title
                'amenities_content', // Your call back function, this is where your form field will go
                'post', // The post type you want this to show up on, can be post, page, or custom post type
                'normal', // The placement of your …
Run Code Online (Sandbox Code Playgroud)

wordpress custom-fields meta-boxes

0
推荐指数
1
解决办法
5503
查看次数

标签 统计

php ×2

wordpress ×2

custom-fields ×1

email ×1

forms ×1

meta-boxes ×1

yii ×1