Note that there are some explanatory texts on larger screens.

plurals
  1. PODrupal - Views - Taxonomy Term ID - custom template - anchors
    text
    copied!<p>Quick version: How do I output a taxonomy term ID in a views template? I just want the numeric ID value. This will be used as a link anchor. </p> <p>Long version:</p> <p>Scenario, I have a view which displays a list of taxonomy terms. That view has a Page and a Block. The Page view is set to display the Block view as a header. That Block view simply contains the taxonomy names. The Page view displays all of the taxonomy content.</p> <p>I want the Block view list to anchor to the items in the Page view:</p> <p><img src="https://i.stack.imgur.com/JsUyy.png" alt="Category page screenshot"></p> <p>This view is already built, the missing part of the equation is getting the anchor links in place. </p> <p>The view currently comprises 3 custom template files:</p> <p>views-view-fields--categories--page.tpl.php</p> <pre><code>&lt;article id="NEED THE TERM ID HERE"&gt; &lt;header&gt; &lt;h2 class="flag-heading"&gt;&lt;?php print $fields['name']-&gt;content; ?&gt; &lt;span&gt;in association with &lt;?php print $fields['field_sponsor']-&gt;content; ?&gt; &lt;/span&gt;&lt;/h2&gt; &lt;/header&gt; &lt;div class="table"&gt; &lt;div class="table-cell"&gt; &lt;?php print $fields['field_category_image']-&gt;content; ?&gt; &lt;/div&gt; &lt;div class="table-cell"&gt; &lt;?php print $fields['description']-&gt;content; ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;/article&gt; </code></pre> <p>views-view-fields--categories--block.tpl.php</p> <pre><code>&lt;li&gt;&lt;a href="NEED THE TERM ID HERE"&gt;&lt;?php print $fields['name']-&gt;content; ?&gt;&lt;/a&gt;&lt;/li&gt; </code></pre> <p>views-view--categories--block.tpl.php</p> <pre><code>&lt;ul&gt; &lt;?php print $rows; ?&gt; &lt;/ul&gt; </code></pre> <p>I've tried using a views contextual filter rewrite on the top block view links, with no luck. </p> <p>All I need is the variable for the TERM ID - I've done a var dump of the available variables, I can see the TID in that list, but have no idea how to reference it in a views-view-fields template file and can find nothing online that answers this most simple of concepts.</p> <p>Screenshots of the Page and Block view setup:</p> <p><img src="https://i.stack.imgur.com/dslKc.png" alt="Block view"> <img src="https://i.stack.imgur.com/9BUfi.png" alt="Page view"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload