Keyword

extra fields image link in slider module...

  • Leslie Fournier
  • Leslie Fournier's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 7 months ago #138237 by Leslie Fournier
extra fields image link in slider module... was created by Leslie Fournier
Hello,
1. I would like the images in the slider module to link to external sites. I've set up extra fields for the slider images and have followed the setting in the template documentation for the slider (clients) module. When I have images - hide and extra fields - show, no image show in the slider. When I have both images and extra fields set to "show" the image links to an "Additional Info" article page that then shows the extra fields image and link. How can I get the slider image to direct link externally?

You can see what happens here by clicking on the Clemson image. - tinyurl.com/q3occ87

Thanks in advance.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 7 months ago #138238 by Krikor Boghossian
Replied by Krikor Boghossian on topic extra fields image link in slider module...
Hello Leslie,

You need to directly render these extrafields.
getk2.org/community/English-K2-Community/171284-Where-to-edit-K2-after-Item-Fields#171348

In that post you will get the snippet needed. All you need to do is change the extrafield alias.

Now in the K2 content template
/templates/numodusversus/html/mod_k2_content/slider/default.php
replace the href value in the image block
<?php if($params->get('itemImage') && isset($item->image)): ?>
		    <a class="moduleItemImage" href="INSERT THE EXTRAFIELD CODE HERE" title="<?php echo JText::_('K2_CONTINUE_READING'); ?> &quot;<?php echo K2HelperUtilities::cleanHtml($item->title); ?>&quot;">
		    	<img src="<?php echo $item->image; ?>" alt="<?php echo K2HelperUtilities::cleanHtml($item->title); ?>"/>
		    </a>
		    <?php endif; ?>

PS. Do not forget to comment out the extrafields loop.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Leslie Fournier
  • Leslie Fournier's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 7 months ago #138239 by Leslie Fournier
Replied by Leslie Fournier on topic extra fields image link in slider module...
Thanks so much for your quick response Krikor. I'm afraid I need a bit more hand-holding. Here is the code I tried (now it just goes back to the home page) -

in items.php
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
<!-- Sponsor Slider extra fields -->
<?php if(isset($this->item->extraFields->SliderImage->value)): ?>
<?php echo $this->item->extraFields->SliderImage->name; ?>
<?php echo $this->item->extraFields->SliderImage->value; ?>
<?php if(isset($this->item->extraFields->ImageLinks->value)): ?>
<?php echo $this->item->extraFields->ImageLinks->name; ?>
<?php echo $this->item->extraFields->ImageLinks->value; ?>
<?php endif; ?>
<?php endif; ?>
<!-- Item extra fields -->
<div class="itemExtraFields">
<h3><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h3>
<ul>
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
<?php if($extraField->value != ''): ?>
<li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<?php if($extraField->type == 'header'): ?>
<h4 class="itemExtraFieldsHeader"><?php echo $extraField->name; ?></h4>
<?php else: ?>
<span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<?php endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<div class="clr"></div>
</div>
<?php endif; ?>

...and in default.php

<?php if($params->get('itemImage') && isset($item->image)): ?>
<a class="moduleItemImage" href="<?php echo ($item->extraField->link->value); ?>" title="<?php echo JText::_('K2_CONTINUE_READING'); ?> &quot;<?php echo K2HelperUtilities::cleanHtml($item->title); ?>&quot;">
<img src="<?php echo $item->image; ?>" alt="<?php echo K2HelperUtilities::cleanHtml($item->title); ?>"/>
</a>
<?php endif; ?>

<?php if($params->get('itemTitle')): ?>
<h2>
<a class="moduleItemTitle" href="<?php echo $item->link; ?>"><?php echo $item->title; ?></a>
</h2>
<?php endif; ?>

<?php /* if($params->get('itemExtraFields') && count($item->extra_fields)): ?>
<div class="moduleItemExtraFields">
<ul>
<?php foreach ($item->extra_fields as $extraField): ?>
<?php if($extraField->value != ''): ?>
<li class="type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<?php if($extraField->type == 'header'): ?>
<h4 class="moduleItemExtraFieldsHeader"><?php echo $extraField->name; ?></h4>
<?php else: ?>
<span class="moduleItemExtraFieldsLabel"><?php echo $extraField->name; ?></span>
<span class="moduleItemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<?php endif; ?>
<div class="clr"></div>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
<?php endif; */?>

<?php if($params->get('itemExtraFields') && count($item->extra_fields)): ?>
<?php if (isset($item->extraFields->image->value) && isset($item->extraFields->link->value)): ?>
<a class="moduleItemImage" href="<?php echo $href; ?>" target="_blank" title="<?php echo $item->title; ?>"><?php echo $item->extraFields->image->value; ?></a>
<?php else: ?>
<span class="moduleItemImage"><?php echo $item->extraFields->image->value; ?></span>
<?php endif; ?>
<?php endif; ?>

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 7 months ago #138240 by Krikor Boghossian
Replied by Krikor Boghossian on topic extra fields image link in slider module...
<?php echo ($item->extraField->link->value); ?>

You need to double check two things.
a) The extrafield's alias.
b) The module's settings. Make sure you have set the extrafields to be visible.
c) The extrafield is a text input NOT a link.

Hint: You can try echoing the value elsewhere in the template to see if it works.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Leslie Fournier
  • Leslie Fournier's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 7 months ago - 10 years 7 months ago #138241 by Leslie Fournier
Replied by Leslie Fournier on topic extra fields image link in slider module...
Still no go.

Changed <?php echo ($item->extraField->link->value); ?> to <?php echo ($item->extraField->text->value); ?>,

Checked the aliases.. I was missing an "s" at the end so fixed that, and checked the module. When Images are hidden and extra fields is set to show I get nothing... images disappear. Maybe I am not understanding "comment out the extra fields loop". Where is the extra fields loop?

...and do I need to do this? - getk2.org/documentation/tips-a-tricks/1129-extra-field-image-type-as-link

OR... do I need an extra field image? Can't I apply the link to the Item Image?

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 7 months ago #138242 by Krikor Boghossian
Replied by Krikor Boghossian on topic extra fields image link in slider module...
Actually <?php echo ($item->extraField->text->value); ?>
is not valid.

Each extrafield has an alias. You need to specify that alias in that particular extrafield's settings (K2) and then use that alias in your code.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Leslie Fournier
  • Leslie Fournier's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 7 months ago #138243 by Leslie Fournier
Replied by Leslie Fournier on topic extra fields image link in slider module...
I'll play around with this. For now I just put the image in the content and linked to it there. It'a a bit limiting but get's the job done.

Thanks for continuing to help.. and on a Sunday even!

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 7 months ago #138244 by Krikor Boghossian
Replied by Krikor Boghossian on topic extra fields image link in slider module...
You 're welcome Leslie.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum