1

I'm trying to pull back related tag entries restricted to the current language.

Say a news entry has a tag of "YMCA" in the English and Welsh versions then the tagger:related pulls back related entires for the welsh and english version.

I want to be able to restrict related tag entries to the current language.

Is this possible?

{exp:channel:entries
  channel="news"
  dynamic="no"
  url_title="{segment_2}"
  limit="3"
  entry_id="{exp:transcribe:entry_ids channel="news"}"
  parse="inward"
}

  {exp:tagger:related entry_id="{entry_id}" custom_fields="news-heading|news-content"}}

    {if tagger:no_entries}<p>No related entries were found.</p>{/if}

    <h2>{tagger:news-heading}</h2>
    {tagger:news-content}

  {/exp:tagger:related}
{/exp:channel:entries}
1
+50

EDIT : Ok so I have a solution for you, however it's not ideal. What I've had to do is use PHP and take advantage of embeds and parse order to make this work.

At first I tried to acomplish this with EE tags, and potentually some embeds but I soon got myself into tag and embed hell, the problem is tagger does not honour transcribe and trandscribe doesn't effect tagger related entries. Therefor rather than nesting tagger tags inside transcribe tags and vice versa what I've done is written a small SQL query that will take care of the linking and filtering for us. Here's your main template:

PHP is On and parsed on Output

{exp:channel:entries
    channel="news"
    dynamic="no"
    url_title="{segment_2}"
    limit="3"
    parse="inward"
}
    <h1>{title}</h1>

    <?php 
        //get the entry ID of the main entry into a PHP variable
        $entry_id = '{entry_id}';

        //use the transcribe:language_links tag to get a list of the availabel abbreviations
        $lang_in = rtrim("{exp:transcribe:language_links has_entry="yes" entry_id="{entry_id}"}{languages}'{abbreviation}',{/languages}{/exp:transcribe:language_links}",',');

        //The magic query, here this one query gets all the entries that the tagger tag is related too like tagger:related does, but then also checks the languages of those returned all at once
        $res = ee()->db->query("
            SELECT tag2.entry_id FROM `exp_tagger_links` as tag1 
                JOIN `exp_tagger_links` as tag2 ON tag1.tag_id = tag2.tag_id
                JOIN `exp_transcribe_entries_languages` as trans1 ON tag2.entry_id = trans1.entry_id 
                JOIN `exp_transcribe_languages` as trans2 ON trans1.language_id = trans2.id
            WHERE tag1.entry_id = '" . $entry_id . "' 
                AND tag1.entry_id != tag2.entry_id 
                AND trans1.language_id != 0
                AND trans2.abbreviation IN (" . $lang_in . ")
        ");

        //now its time to process the results if any
        $eids = "";
        if ( $res-> num_rows() > 0 ){
            foreach ( $res->result_array() as $row ){
                $eids .= $row['entry_id'] . "|";
            }
        }
        $eids = rtrim($eids, "|");
    ?>

    {!-- now we feed the result of our PHP query into the embed --}
    {embed="_site/part" eids="<?php echo $eids; ?>"}

{/exp:channel:entries}

Ok, so now we have to run PHP based on tag output so we can't then use the PHP to feed other tags parameters, so what we do here is take advantage of an embed template. Embed templates are processed after PHP on Output so we can feed our PHP into an embed, as per the above. My child template is fairly simple but you can expand this to whatever you like, as we are now using a standard channel:entries loop to display the filtered entries!

{exp:channel:entries channel="news" entry_id="{embed:eids}" dynamic="no" transcribe="disable"}
    <h2><sup>{entry_id}</sup>{title}</h2>
{/exp:channel:entries}

I spun up an example Where I had :

  • Entry "One" in English(id:1) and Welsh(id:2), both tagged with "YMCA"
  • Entry "Two" in English(id:3) Only, tagged with "YMCA"
  • Entry "Three" in English(id:4) and Welsh(id:5), just Welsh version tagged with "YMCA"
  • Entry "Four" in English(id:6) and Irish(id:7), just Irish version tagged with "YMCA"

Therefor of we just pull the entire related entries list for "YMCA" we would get id's ; 1, 2, 3, 5 & 7. To prove the test we would expect that when I view your template for "Entry One" we would get (any entry tagged with YMCA available in English or Welsh so) just the id's ; 2, 3 & 5.

Here's a copy paste of my result :

One

2One

3Two

5Three

This produces the correct result. For completeness, versions used are : EE 2.10.1, Tagger 3.2.1, Transcribe 1.6.2

  • Thanks Blatant, shame there isn't a native way to do this with the modules tags. Will give this a go later once I've got the kids to bed. – MBM May 21 '15 at 18:41
  • I'm not saying it can't be done with native tags but it fried my brain once I got to 3 embeds and large language tags inside parameters all over the shop. It got to the point that I could achive what I wanted with 6 lines of PHP, or fight multiple mebeds/tags forever. For me this screams "roll your own" PHP as the most efficient solution. – Blatant May 22 '15 at 8:50
  • Thinking about it, the main roadblock as I see it is that you can't ask transcribe "what language options are available for entry X", with a tag like that you could achieve this with tags and some conditionals. Perhaps it could go as a feature request, a tag like {exp:transcribe:entry_languages entry_id="X"}{languages}{abbreviation}{/languages}{/exp:transcribe:entry_languages} – Blatant May 22 '15 at 8:52
  • Might speak with EE Harbor and see put it forward as a feature request. Haven't had time to test it yet with work commitments but bounty is yours. Thanks Blatant, much appreciated the effort you've gone to with this. – MBM May 22 '15 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.