Monday, May 21st

Last update05:36:30 AM GMT

Font Size

Screen

Profile

Layout

Menu Style

Cpanel
Welcome, Guest
Username Password: Remember me

K2 Templating ?
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: K2 Templating ?

K2 Templating ? 11 months, 3 weeks ago #4269

  • MartinB
  • OFFLINE
  • Expert Boarder
  • Posts: 90
  • Karma: 0
Hi all,

I'm dipping my toes into the murky world of K2 templating after Norm's presentation to MJUG last week (thanks Norm!)

Moving stuff around via css is pretty straight forward however I *think* I need a functional change and this is where my lack of PHP is a hinderence... assuming that's the issue/solution of course

I'm wanting to create a category/blog view of my items (articles) that include showing my extra fields in the blog layout. I've checked all the K2 item and category options that should "show extra fields" but no luck. I've also looked at using the JB Microblog module, and that doesn't seem to offer the soultion either.

If I'm not mistaken I need to move the "catItemExtraFields" section of code from with the file category_item.php however I'm not sure where it needs to be moved to ??

Suggestions ?

Re: K2 Templating ? 11 months, 3 weeks ago #4270

  • buipy001
  • OFFLINE
  • Administrator
  • Posts: 250
  • Karma: 12
This is for k2 2.4.2 I think.

Add this code to your category_items.php file in your K2 templates folder whether it is a template override or a part of the core.

<?php if($this->item->params->get('catItemExtraFields') && count($this->item->extra_fields)): ?>
<!-- Item extra fields -->
<div class="catItemExtraFields">
<h4><?php echo JText::_('Additional Info'); ?></h4>
<ul>
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
<li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<span class="catItemExtraFieldsLabel"><?php echo $extraField->name; ?></span>
<span class="catItemExtraFieldsValue"><?php echo $extraField->value; ?></span>
</li>
<?php endforeach; ?>
</ul>
<div class="clr"></div>
</div>
<?php endif; ?>
 

I may have moddified the code but I can't remember now.
The only limitation is your imagination
www.pbwebdev.com.au

Twitter: twitter.com/astroboysoup
Facebook: www.facebook.com/pbwebdev

Re: K2 Templating ? 11 months, 3 weeks ago #4271

  • MartinB
  • OFFLINE
  • Expert Boarder
  • Posts: 90
  • Karma: 0
Hi Peter

Thanks for that - I already have a similar looking (same ?) code block in my category_items.php file as part of the 2.4.1 install ?

 
 
<?php if($this->item->params->get('catItemExtraFields') && count($this->item->extra_fields)): ?>
<!-- Item extra fields -->
<div class="catItemExtraFields">
<h4><?php echo JText::_('Additional Info'); ?></h4>
<ul>
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
<li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<span class="catItemExtraFieldsLabel"><?php echo $extraField->name; ?></span>
<span class="catItemExtraFieldsValue"><?php echo $extraField->value; ?></span>
</li>
<?php endforeach; ?>
</ul>
<div class="clr"></div>
</div>
<?php endif; ?>
 
 


I was wondering if the Blog view truncated anything after the intro text and though if I moved the code up higher I'd bypass that - coding never was my strong suit
Last Edit: 11 months, 3 weeks ago by MartinB. Reason: updated

Re: K2 Templating ? 11 months, 3 weeks ago #4273

  • MartinB
  • OFFLINE
  • Expert Boarder
  • Posts: 90
  • Karma: 0
Ok clearly not enough beer has been consumed today to ensure proper focus

I was using the wrong menu type (K2 Latest rather than K2 Category) and by default the functionality is there

So I'm all sorted - cheers Peter once more
  • Page:
  • 1
Time to create page: 0.64 seconds
You are here: Forum