テンプレートはjQuery .load()経由で読み込まれますが、{%js%}タグは含まれません ベストアンサー In Craft 3, the {% JS %} tag places the JavaScript code just before the closing </body> tag in the rendered HTML document by default. This means that the rendered <script> tag will not be in the #newAddressForm element, but will be rendered just before the closing </body> tag. So if you are loading the rendered template using jQuery’s .load() function and specifying the #newAddressForm element, the <script> tag will be excluded from the injected code as it isn’t within the #newAddressForm element. Your best bet is to inline the <script> tag within the Twig template rather than using the {% JS %} tag to include it. That way you can ensure that the code will be included in the #newAddressForm element as you need it. More details of the {% JS %} tag can be found in the Craft 3 docs: https://docs.craftcms.com/v3/dev/tags/js.html
もっと読むタグ: templating
エントリのないカテゴリのタグを非表示にするにはどうすればよいですか?
エントリのないカテゴリのタグを非表示にするにはどうすればよいですか? ベストアンサー Here’s a good tutorial on how to achieve this: https://straightupcraft.com/articles/how-do-i-only-display-a-list-of-categories-that-have-entries-and-hide-empty-categories
もっと読む改行を含むプレーンテキストフィールドから単一行を作成する方法
改行を含むプレーンテキストフィールドから単一行を作成する方法 ベストアンサー 私はこれのために少しマクロを作った: {% macro splitText(text) %} {% set text = text|nl2br|raw %} {% set text = ” ~ text|replace(”, ‘ ‘) ~ ” %} {{ text|raw }} {% endmacro %} それを少し微調整する必要があるかもしれませんが、これは私のために働いたものです。
もっと読む配列をマージした後のエントリを区別するにはどうすればよいですか?
配列をマージした後のエントリを区別するにはどうすればよいですか? ベストアンサー 私は完全にそれを持っているかどうかは分かりませんが、あなたはオブジェクトのクラスを {% if element is instance of (‘craft\elements\Entry’) %} または switch ステートメントを介して {% switch className(element) %} {% case ‘craft\elements\Entry’ %}
もっと読む前または次の2つのエントリを取得する方法
前または次の2つのエントリを取得する方法 ベストアンサー チャンネルでは、これは、ポスト日付が現在のエントリーのポスト日付の前後の次のエントリーになります。要素のクエリは次のようになります。 {% set query = craft.entries .section(‘blog’) .id(‘not ‘ ~ entry.id) .limit(2) %} {% set prevEntries = clone(query) .postDate(‘<= ‘ ~ entry.postDate.timestamp) .order(‘postDate desc’) .all() %} {% set nextEntries = clone(query) .postDate(‘>= ‘ ~ entry.postDate.timestamp) .order(‘postDate asc’) .all() %} エントリをタイトルで並べ替えると、次のようなものが動作します: {% set prevEntries = clone(query) .title(‘<= ‘ ~ entry.title) .order(‘title desc’) .all() %} {% set nextEntries = clone(query) .title(‘>= ‘ ~ entry.title) .order(‘title asc’) .all() %}
もっと読むCommerce:Craft TransactionモデルでStripeオブジェクトを読み込む
Commerce:Craft TransactionモデルでStripeオブジェクトを読み込む ベストアンサー 申し訳ありませんが、適切な答えはありません
もっと読む資産volumneの場所とIDを取得する
資産volumneの場所とIDを取得する ベストアンサー もちろん。あなたは、例えば、あなたが望むようにボリュームを得ることができます {% set volume = craft.app.getVolumes().getVolumeByHandle(‘images’) %} あなたが資産を持っているならば {% set asset = craft.assetFieldHandly.one() %} {% set volume = asset.getVolume() %} 情報を出力する {{ volume.path }} {{ volume.id }} {{volume.path}} にエイリアスが含まれている場合、解決されたパスを表示するために {{alias(volume.path)}}
もっと読むネスティングブロックタグが機能しません
ネスティングブロックタグが機能しません ベストアンサー 残念ながら、インクルードされたテンプレートは、親テンプレート内のブロックの内容やそのレイアウトを上書きすることはできません。 seo ブロックを page.twig からオーバーライドするだけで、必要な処理を行う必要があります。 {% extends ‘layout.twig’ %} {% block main %} some content.. {% include ‘pagination.twig’ %} {% endblock %} {% block seo %} <link href=”url” rel=”canonical”> {% endblock %}
もっと読むTwigを使用してフィールドのタイプを取得するにはどうすればよいですか?
Twigを使用してフィールドのタイプを取得するにはどうすればよいですか? ベストアンサー className 関数を使用することができます {% switch className(field) %} {% case ‘craft\fields\PlainText’ %} {% case ‘craft\fields\Dropdown’ %}
もっと読む検索で複数のパラメータを表示する際の問題
検索で複数のパラメータを表示する際の問題 ベストアンサー 申し訳ありませんが、適切な答えはありません
もっと読む