1

多言語サイトを開発しています。

一部の言語は右から左へのレイアウトを使用し、一部は左から右へのレイアウトを使用します。

そのため、一部のビュースクリプトには、自動的にロードする別のRTLビュースクリプトがあります。

ユーザーがRTLであるかどうかをチェックし、そうである場合はファイルのサフィックスに「.rtl」を追加するプラグインを作成しました。Zend_Controller_Action_HelperBroker:: getExistingHelper('ViewRenderer')-> setViewSuffix('rtl.phtml');

問題は、すべてのビュースクリプトにrtlビュースクリプトがあるわけではないため、ファイルが存在するかどうかを確認したいということです。

この問題は、コントローラーで$ this-> render('someScript')を実行すると、私が知る限り、.rtlスクリプトが存在するかどうかを確認する方法がありません。

つまり、アクションが終了した後、レンダリングされる前に接続する方法(イベント)はありますか?

たぶん私はカスタムビューレンダラーを書くべきですか?

ありがとう。

4

1 に答える 1

0

If the RTL check can only happen after an action has been executed, you could create an action helper, which uses the postDispatch hook to set the viewSuffix via the ViewRenderer and retrieve the path to the view script. Using the view scriptPath and the viewRenderer getViewScript(), you can create the absolute path to the file. It is not a particularly pretty way to accomplish your goals, though.

It might be an idea to create two scriptPaths, one for the LTR and another for the RTL. When the user uses a RTL language, you can add the RTL scriptPath to the view scriptPath stack. That way, Zend_View will first check the RTL directory and use the LTR directory as a fallback.

于 2012-01-06T21:07:43.367 に答える