我最近使用安装配置文件将一个站点升级到了Drupal7.59:
Commerce Kickstart (commerce_kickstart-7.x-2.54)
以前有一个功能已经添加到核心,但现在由于升级而被删除。这不应该被添加到核心中,我也不确定为什么会这样。我已经把这个函数添加回去了,它没有像以前那样工作,所以我不确定我还需要做什么改变才能让它工作。
下面是在/profiles/commerce_kickstart/themes/commerce_kickstart_admin/template.php中找到的函数-
function commerce_kickstart_admin_commerce_price_formatted_components($variables) {
// Add the CSS styling to the table.
drupal_add_css(drupal_get_path('module', 'commerce_price') . '/theme/commerce_price.theme.css');
// Build table rows out of the components.
$rows = array();
foreach ($variables['components'] as $name => $component) {
$rows[] = array(
'data' => array(
array(
'data' => $component['title'],
'class' => array('component-title'),
),
array(
'data' => $component['formatted_price'],
'class' => array('component-total'),
),
),
'class' => array(drupal_html_class('component-type-' . $name)),
);
}
if($variables['components']['discount']['price']['amount']){
unset($rows[0]);
unset($rows[2]);
}else{
$rows = array_splice($rows, 2);
}
return theme('table', array('rows' => $rows, 'attributes' => array('class' => array('commerce-price-formatted-components'))));
}有没有人能给出一些关于如何让它工作的建议?它似乎甚至没有被调用。
评论中的其他信息:
it's a function in the profile?是
Was the function added afterwards (as in "Never hack core")?是的,看起来是这样的。
Or was it removed by the maintainers?看起来不像是任何官方发行版的一部分
Do you use some version control system like Git?是的。根据回购,在14/05/2015 12:18增加此功能。
Have you checked the profile's release notes and issue queue?看了看,但什么也没看到。
发布于 2018-05-25 02:32:40
感谢您添加额外的信息!
好吧,如果这真的是自定义代码,那么它一开始就不应该被添加到配置文件中。永远不要向任何核心或contrib文件添加自定义代码。因为一旦你更新,它就会被删除。就像它发生在你身上一样。
我猜这个自定义函数最重要的部分是drupal_add_css(drupal_get_path('module', 'commerce_price') . '/theme/commerce_price.theme.css');,这个commerce_price.theme.css可能也被删除了。
除此之外,很难说清楚,而且我也不是商务模块方面的专家。所以,我现在要做的是系统地缩小这个问题的范围。
dpm()函数的帮助下,除此之外,找到添加代码的人,并询问他们为什么和这段代码在做什么。并告诉他们永远不要再破解核心或contrib代码:)
祝好运!
https://stackoverflow.com/questions/50503450
复制相似问题