小编s-h*_*ter的帖子

如何在Magento中修改或删除addSuccess消息?

例如,以下操作将添加将插入页面的消息:

- 单击addtocart按钮时,将显示一条消息,说明产品是否成功添加.代码在app/code/core/Mage/Checkout/controllers/CartControllers.php中

$message = $this->__('%s was added to your shopping cart.', Mage::helper('core')->escapeHtml($product->getName()));
$this->_getSession()->addSuccess($message);
Run Code Online (Sandbox Code Playgroud)

- 提交产品评审时,会显示一条消息,表示评审已被接受审核.代码在app/code/core/Mage/Review/controllers/ProductController.php中

$session->addSuccess($this->__('Your review has been accepted for moderation.'));
Run Code Online (Sandbox Code Playgroud)

以上两个只是示例,还有更多其他类似的消息显示在某些操作上.

我知道如何覆盖它,更改或删除消息.对于addtocart消息,也可以通过转到管理面板来关闭它.

我相信有一种更好的方法来修改这些消息,而不是创建一个模块并重写该函数只是为了修改消息或删除它.

有谁知道修改或删除这些addSuccess消息的更好方法?在调用addSuccess()函数并添加消息后,我们如何修改或删除这些消息?

magento

3
推荐指数
1
解决办法
1万
查看次数

如何在 ConstraintLayout 中垂直或水平放置视图?

这是具有 3 个视图的 Constraintlayout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/iv_profile_image"
        android:layout_width="100dp"
        android:layout_height="100dp"
        app:layout_constraintBottom_toTopOf="@+id/tv_name"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <TextView
        android:id="@+id/tv_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="@+id/iv_profile_image" />

    <TextView
        android:id="@+id/tv_headline"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="@+id/tv_name" />

</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

结果:

在此输入图像描述

正如您所看到的,每个视图之间都有很大的差距。我怎样才能消除这些间隙并使它们在屏幕上居中。我可以使用RelativeLayout或LinearLayout轻松实现这一点,但如何在这个ConstraintLayout中做到这一点?ConstraintLayout 是否应该替代relativelayout?

android android-layout android-constraintlayout

3
推荐指数
1
解决办法
4591
查看次数

方括号的函数声明如何在Node.js/Javascript中工作?

第一次看到像这样在Node.js的宣告功能.简而言之,代码与此类似

'use strict';
const Actions = {
  ONE: 'one',
  TWO: 'two',
  THREE: 'three'
};
class FunMap {

  run(action) {
    const map = this;
    map[action]();
  }

  [Actions.ONE] () {
    console.log("Performing action one");
  }

  [Actions.TWO] () {
    console.log("Performing action two");
  }

  [Actions.THREE] () {
    console.log("Performing action three");
  }

}

var funMap = new FunMap();
funMap.run('one');
funMap.run('two');
funMap.run('three');
Run Code Online (Sandbox Code Playgroud)

上面的程序将打印出来

Performing action one
Performing action two
Performing action three
Run Code Online (Sandbox Code Playgroud)

在Node.js/Javascript中是否有这种类型的函数声明的技术名称?

这一行如何将所有这些(通过使用带有字符串常量的方括号声明的函数)放入FunMap对象的属性函数中?

const map = this;
Run Code Online (Sandbox Code Playgroud)

[]javascript类中的方括号表示法是否引用了类本身?

javascript function square-bracket node.js ecmascript-6

3
推荐指数
1
解决办法
1071
查看次数

Chrome 上不一致的字体大小渲染问题

我在我的网站上遇到了 css 问题。所有页面的字体大小不一致。区别在于一个版本的大字体和一个版本的常规小字体。小字体是我喜欢的。如果页面以大字体显示内容,重新加载页面几次后,它会变回小字体,如果您右键单击并选择检查元素,它也会立即变回小字体。因此,我不确定如何ping 点问题。这是屏幕截图,一张大字体,一张小字体,我更喜欢小字体。 大字体

小字体

html css fonts google-chrome

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

在Python BaseHTTPServer中获取GET和POST请求数据

尝试获取GET和POST数据时出现此错误。

Exception happened during processing of request from ('127.0.0.1', 62635)
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 655, in __init__
    self.handle()
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
    method()
  File "server1.py", line 30, in do_GET
    print form.getvalue["foo"]
TypeError: 'instancemethod' object has no attribute '__getitem__'
Run Code Online (Sandbox Code Playgroud)

代码

from BaseHTTPServer import …
Run Code Online (Sandbox Code Playgroud)

python post get

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

如何将函数传递给Kotlin中的数据类?

当我在kotlin游乐场中运行以下内容时,它会输出错误,没有别的.以下代码有什么问题?这很简单,我将一个函数作为其中一个初始化参数传递给数据类,然后在数据类实例上调用此函数.不允许将函数传递给Kotlin中的数据类吗?

data class Person(val name: String,
                  val age: Int = 0,
                  val showMsg : (msg: String) -> Unit)


fun main(args: Array<String>) {
    val p = Person(name="Bob", age=29, {msg -> println(msg)})
    p.showMsg("Hello, world!")
}
Run Code Online (Sandbox Code Playgroud)

function kotlin

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

如何使用 Kotlin 的 Parcelize 对 HashMap 进行 Parcelize?

这就是我尝试 @Parcelize a HashMap 的方法

@Parcelize
class DataMap : HashMap<String, String>(), Parcelable
Run Code Online (Sandbox Code Playgroud)

但它甚至无法通过以下代码进行编译。

val data = DataMap()
data.put("a", "One")
data.put("b", "Two")
data.put("c", "Three")

val intent = Intent(this, DetailActivity::class.java)
intent.putExtra(DATA_MAP, data)
startActivity(intent)
Run Code Online (Sandbox Code Playgroud)

它在这一行抱怨intent.putExtra(DATA_MAP, data)错误:

Overload resolution ambiguity. All these functions match.

public open fun putExtra(name: String!, value: Parcelable!): Intent! defined in android.content.Intent

public open fun putExtra(name: String!, value: Serializable!): Intent! defined in android.content.Intent
Run Code Online (Sandbox Code Playgroud)

android parcelable kotlin

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

如何为 Exoplayer 启用/支持 TLS 1.1,1.2?

错误:SSL 握手中止:ssl=0x676a5680:SSL 库失败,通常是协议错误

根据此Android 文档,API 16+ 支持TLS 1.11.2 ,但在 API 20+ 之前默认不启用。我找到了一些解决方案(此处此处此处此处),用于启用 OkHttp 的 TLS 1.1 和 1.2 支持。如何启用 Exoplayer 的 TLS 1.1/1.2 支持?我发现的关于 Exoplayer TLS 1.1/1.2 支持的唯一帖子来自此 github问题,该问题建议改为在此处提出问题。

“07-27 13:21:09.817 8925-9065/com.ftsgps.monarch E/ExoPlayerImplInternal:源错误。com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException:无法连接到https://liveStream/LIVE -0089000D05/manifest.mpd 在 com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:194) 在 com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:147) 在 com .google.android.exoplayer2.upstream.DataSourceInputStream.checkOpened(DataSourceInputStream.java:102) 在 com.google.android.exoplayer2.upstream.DataSourceInputStream.open(DataSourceInputStream.java:65) 在 com.google.android.exoplayer2.upstream .ParsingLoadable.load(ParsingLoadable.java:129) 在 com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:308) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) )在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 在 java.lang.Thread.run(Thread.java:841) 引起:javax.net.ssl.SSLHandshakeException:javax.net。 ssl.SSLProtocolException:SSL握手中止:ssl=0x722c3af8:SSL库失败,通常是协议错误错误:14077410:SSL例程:SSL23_GET_SERVER_HELLO:sslv3警报握手失败(外部/openssl/ssl/s23_clnt.c:744 0x689d8f10:0x00000 000) ”

这种情况仅发生在 API 21 …

android exoplayer tls1.2

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