snipt

Ctrl+h for KB shortcuts

Text only

Drupal 7: View entity translation field duplicated issue

If you have a Sort Criteria on the title_field you may have your nodes appear twice.
To fix this, you just need to add a Filter Criteria on the title_field:language (Current user's language) and it works !
https://snipt.net/embed/8f519940f0965984452507bddd0000ff/
https://snipt.net/raw/8f519940f0965984452507bddd0000ff/
8f519940f0965984452507bddd0000ff
text
Text only
2
2016-09-24T18:54:27
True
False
True
Jun 12, 2013 at 06:12 AM
/api/public/snipt/63929/
drupal-7-view-entity-translation-field-duplicated-issue
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>If you have a Sort Criteria on the title_field you may have your nodes appear twice. </span><span id="L-2"><a name="L-2"></a>To fix this, you just need to add a Filter Criteria on the title_field:language (Current user&#39;s language) and it works ! </span></pre></div> </td></tr></table>
"drupal 7", entity, field, i18n, translation, views

PHP

Add theme suggestion by view_mode, field_name and bundle for fields

1
2
3
4
5
6
7
8
<?php

function MYTHEME_preprocess_field(&$variables, $hook) {
    $element = $variables['element'];

    // Add specific suggestions that can override the default implementation.
    $variables['theme_hook_suggestions'][] = 'field__' . $element['#bundle'] . '__' . $element['#view_mode'] . '__' . $element['#field_name'];
}
https://snipt.net/embed/d0b74622f7856b3a8041f90cf1a8f390/
https://snipt.net/raw/d0b74622f7856b3a8041f90cf1a8f390/
d0b74622f7856b3a8041f90cf1a8f390
php
PHP
8
2016-09-25T22:34:50
True
False
False
Jan 24, 2013 at 09:55 AM
/api/public/snipt/54392/
add-theme-suggestion-by-view_mode-field_name-and-bundle-for-fields
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="k">function</span> <span class="nf">MYTHEME_preprocess_field</span><span class="p">(</span><span class="o">&amp;</span><span class="nv">$variables</span><span class="p">,</span> <span class="nv">$hook</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="nv">$element</span> <span class="o">=</span> <span class="nv">$variables</span><span class="p">[</span><span class="s1">&#39;element&#39;</span><span class="p">];</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a> <span class="c1">// Add specific suggestions that can override the default implementation.</span> </span><span id="L-7"><a name="L-7"></a> <span class="nv">$variables</span><span class="p">[</span><span class="s1">&#39;theme_hook_suggestions&#39;</span><span class="p">][]</span> <span class="o">=</span> <span class="s1">&#39;field__&#39;</span> <span class="o">.</span> <span class="nv">$element</span><span class="p">[</span><span class="s1">&#39;#bundle&#39;</span><span class="p">]</span> <span class="o">.</span> <span class="s1">&#39;__&#39;</span> <span class="o">.</span> <span class="nv">$element</span><span class="p">[</span><span class="s1">&#39;#view_mode&#39;</span><span class="p">]</span> <span class="o">.</span> <span class="s1">&#39;__&#39;</span> <span class="o">.</span> <span class="nv">$element</span><span class="p">[</span><span class="s1">&#39;#field_name&#39;</span><span class="p">];</span> </span><span id="L-8"><a name="L-8"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
"drupal 7", bundle, field, field_name, hook, suggestion, template, view_mode
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.