I've managed to get this working in the item.php page here:
detroitrevival.org/links/latest
However, when trying to get it to work in a module using the same code, I get the following error (here
detroitrevival.org/links/test ):
Fatal error: Using $this when not in object context in /home/totalinf/public_html/detroitrevival.org/modules/mod_k2_content/tmpl/Quotes/default.php on line 85
(The first line in the code below is line 85)
Here is the code that I am using in the default.php file here lines 83-98: /modules/mod_k2_content/tmpl/Quotes (please note that I created a sub-template):
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
<!-- Item extra fields -->
<div class="mb-wrap mb-style-1">
<div class="mb-thumb"></div>
<blockquote class="type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<p><?php echo $this->item->extraFields->k_quote->value ?> </p>
</blockquote>
<div class="mb-attribution">
<p class="mb-author"><?php echo $this->item->extraFields->q_author->value ?> </p>
<cite><?php echo $this->item->extraFields->q_citation_source->value ?></cite>
</div>
</div>
<div class="clr"></div>
</div>
<?php endif; ?>
What I am trying to do is display the latest content (1 item) from the 'Quote' K2 category, in a module (basically ONLY the extra fields display in a module). The content is entered in the Extra Fields in the K2 item.
I've tried the solutions mentioned in the following thread but I'm not having any luck.
getk2.org/community/New-to-K2-Ask-here-first/161676-Display-specific-extra-field-in-module-position-
Thanks in advance for your wisdom :-)
Respectfully,
EJ Lear