<p>Ok, I believe this does what you want:</p>

<pre><code>{% if entry.tags1 | length %}

    {# get tag names from our current entry #}
    {% set entryTagNames = [] %}
    {% for tag in entry.tags1 %}
        {% set entryTagNames = entryTagNames | merge([tag.name]) %}
    {% endfor %}

    {% if entryTagNames | length %}

        {# get tags from the other tag group with the same names #}
        {% set otherTags = craft.tags({ group: 'group2', name: entryTagNames }) %}

        {# get entries related to these tags #}
        {% set retaledEntries = craft.entries({ section: 'news', relatedTo: otherTags }) %}

        {# output related entries. just debugging that this actually works #}
        {% for relatedEntry in retaledEntries %}
            {{ relatedEntry }}&lt;br&gt;
            {% for relatedEntryTag in relatedEntry.tags2 %}
                - {{ relatedEntryTag.name }}&lt;br&gt;
            {% endfor %}
            &lt;br&gt;
        {% endfor %}

    {% endif %}

{% endif %}
</code></pre>

<p>My first section, which the current entry is in, has a field named <strong>tags1</strong>, connected to the tag group <strong>group1</strong>. My second section is named <strong>news</strong>, has a field named <strong>tags2</strong>, connected to the tag group <strong>group2</strong>.</p>

<p>It seems a bit sketchy to rely on tag <em>names</em>, but. </p>

CC BY-SA 3.0
2014-09-15T09:19:41.610Z
2014-09-15T09:19:41.610Z
André Elvan
<p>I'm working on a site that has two different entry types (e.g., "blog" and "photos"), and each type has it's own tag group. When viewing a particular entry, I'd like to display related entries found in both entry types.</p>

<p>So, for example, let's say that I've written "Entry A" and "Entry B" -- "Entry A" is in "blog" and "Entry B" is a "photos." They both have the same tag ("foo"), but that tag exists in each entry type's respective tag group.</p>

<p>If I view "Entry A," can I display a list of related entries that includes "Entry B" even though the tag that they share isn't in the same tag group?</p>

CC BY-SA 3.0
2014-09-13T21:30:07.667Z
So, it's not the same tag? It's two different tags, they just happen to have the same name?
André Elvan
CC BY-SA 3.0
2014-09-15T01:38:58.443Z
That is correct. Technically, they're two different tags in two different tag groups assigned to two different entry types.
Jason Morehead
<tags><relations>
Display related entries across different entry types using tags in different tag groups?
# Display related entries across different entry types using tags in different tag groups?

(Asked by: username_0 on 2014-09-13)

I'm working on a site that has two different entry types (e.g., "blog" and "photos"), and each type has it's own tag group. When viewing a particular entry, I'd like to display related entries found in both entry types.

So, for example, let's say that I've written "Entry A" and "Entry B" -- "Entry A" is in "blog" and "Entry B" is a "photos." They both have the same tag ("foo"), but that tag exists in each entry type's respective tag group.

If I view "Entry A," can I display a list of related entries that includes "Entry B" even though the tag that they share isn't in the same tag group?

**Tags:** tags, relations
> **Comments:**
> **username_1**: So, it's not the same tag? It's two different tags, they just happen to have the same name?  
> **username_0**: That is correct. Technically, they're two different tags in two different tag groups assigned to two different entry types.  

---

## 1 answers

### Answer by username_1 on 2014-09-15. Score: 4 | Accepted answer

Ok, I believe this does what you want:
{% if entry.tags1 | length %}

    {# get tag names from our current entry #}
    {% set entryTagNames = [] %}
    {% for tag in entry.tags1 %}
        {% set entryTagNames = entryTagNames | merge([tag.name]) %}
    {% endfor %}

    {% if entryTagNames | length %}

        {# get tags from the other tag group with the same names #}
        {% set otherTags = craft.tags({ group: 'group2', name: entryTagNames }) %}

        {# get entries related to these tags #}
        {% set retaledEntries = craft.entries({ section: 'news', relatedTo: otherTags }) %}

        {# output related entries. just debugging that this actually works #}
        {% for relatedEntry in retaledEntries %}
            {{ relatedEntry }}
            {% for relatedEntryTag in relatedEntry.tags2 %}
                - {{ relatedEntryTag.name }}
            {% endfor %}
            
        {% endfor %}

    {% endif %}

{% endif %}

My first section, which the current entry is in, has a field named tags1, connected to the tag group group1. My second section is named news, has a field named tags2, connected to the tag group group2.
It seems a bit sketchy to rely on tag names, but.


---

