English 中文(简体)
我在哪些地方界定了卡纳克民阵的观念职能?
原标题:Where do I define view functions in CakePHP?

我有一个更灵活的程序来显示一次活动的“日期”。

        if($event[ Event ][ is_multi_day ]){
        if( date( n ,strtotime($event[ Event ][ start_day ]) ) ==  date( n ,strtotime($event[ Event ][ end_day ])) )
            $date = date( j ,strtotime($event[ Event ][ start_day ])).  -  .
                date( j ,strtotime($event[ Event ][ end_day ])).   .
                date( M ,strtotime($event[ Event ][ end_day ]));
        else
            $date = date( j ,strtotime($event[ Event ][ start_day ])).   .
                date( M ,strtotime($event[ Event ][ start_day ])).  -  .
                date( j ,strtotime($event[ Event ][ end_day ])).   .
                date( M ,strtotime($event[ Event ][ end_day ]));    

    }else{
        $date = date( j M , strtotime($event[ Event ][ start_day ]));
    }

I have to include that code block in every page I display an event. How do I define a function for this, which can be called from views I want?

最佳回答

期望大家再次利用这一机会,展示一些事件,你的法典在这种局势中将远远不够理想。

我认为,你可以减少这一界限:

if( date( n ,strtotime($event[ Event ][ start_day ]) ) ==  date( n ,strtotime($event[ Event ][ end_day ])) )
)

:

if($event[ Event ][ start_day ]==$event[ Event ][ end_day ])

(或与储存价值不作格式比较的类似情况。) 格式是为了显示目的,而不是算法比较。

为此:

date( j ,strtotime($event[ Event ][ end_day ])).   .date( M ,strtotime($event[ Event ][ end_day ]));

:

date( j M ,strtotime($event[ Event ][ end_day ]));

......和其他地方类似its。 如果这种情况存在,你需要减少不必要的职能要求,避免扼杀。

个人而言,由于这是一种显示功能,我将其保留在事情的旁边(而不是控制人),而我可能把它当作一个具有传承参数的内容——见

问题回答

如果掌握你重新操纵(如所示)的原始数据,而且你只是想归还显示价值,那么我就会形成一个组成部分,并在控制人员一级这样做。 如果你想要包括介绍标记和(或)逻辑,那么一个因素很可能是你所期待的。





相关问题
PHP Framework: Ebay Like Site

I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...

specifying date format when using $form->inputs() in CakePHP

I am wondering if there is a way to specify the date format in the forms created using CakePHP s $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() ...

Using DISTINCT in a CakePHP find function

I am writing a CakePHP 1.2 app. I have a list of people that I want the user to be able to filter on different fields. For each filterable field, I have a drop down list. Choose the filter ...

Assistance with CakePHP model relationships

How would I represent the following in a CakePHP model? Product ======= product_id .... Cart ==== cart_id .... Carts_Products ============== cart_id product_id quantity

Prevent controller from trying to autoload model

I am a beginning Cake user and trying to do some work on an already existing application. Running into a problem when I create a new controller. I have created StoreController and when I try to call ...

热门标签