Hello everyone,
I have now been trying for a couple of days to get this seemingly simple syntax to work for me:
I have now been trying for a couple of days to get this seemingly simple syntax to work for me:
Y
13 years 1 month ago #118640
What type is your extrafield? If it is link then you cannot put it inside another link since it generates the whole <a> element and your output would be
<a href="<a href="<?php echo $this->item->extraFields->external_url->value; ?>".
You can change it to textfield if you want to be able to generate the link through your php file.
<a href="<a href="<?php echo $this->item->extraFields->external_url->value; ?>".
You can change it to textfield if you want to be able to generate the link through your php file.
Topic Author
13 years 1 month ago #118641
Thank you for your reply!
The field type was 'link' and I've now changed it to text field per your suggestion.
However, it's still not working. It just links to the root url of the site and the whole expression/line of php code just outputs a "/" when I go to 'Inspect element' in the browser.
Is the path to the extra field faulty?
The field type was 'link' and I've now changed it to text field per your suggestion.
However, it's still not working. It just links to the root url of the site and the whole expression/line of php code just outputs a "/" when I go to 'Inspect element' in the browser.
Is the path to the extra field faulty?
Y
13 years 1 month ago #118642
Is it possible for you to provide the code snippet of the whole block you are trying to modify from your file?
Also double check that the alias of the extrafield is correct.
Also double check that the alias of the extrafield is correct.
Topic Author
13 years 1 month ago #118643
<!-- Item Image -->
<?php if($this->item->params->get('catItemImage') && !empty($this->item->image)): ?>
<div class="catItemImageBlock">
<span class="catItemImage">
<a href="<?php echo $this->item->extraFields->external_url->value; ?>" title="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>">
<img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" style="width:<?php echo $this->item->imageWidth; ?>px; height:auto;" />
</a>
</span>
<div class="clr"></div>
</div>
<?php endif; ?>I tried changing the alias to "url" to make sure it wasn't a typo or something.
Also, I'm wondering if the 'extra field group' has any part to play in this?
EDIT: Wow, code gets really messy to look at.. Hope you can read it.
2. EDIT: Cleaned it up just a bit.
Y
13 years 1 month ago #118644
Have you Enabled the parameter for the extra fields to Show in the category listing?
Topic Author
13 years 1 month ago #118645
Nope, that was the problem apparently. Thanks for suggesting that.
I had it set to hide the extra field because I didn't want it to actually show on the page, just be there to supply the link for the image.
So now I just need to disable whatever code is displaying the extra field and I'm good to go.
Thank you for your help!
I had it set to hide the extra field because I didn't want it to actually show on the page, just be there to supply the link for the image.
So now I just need to disable whatever code is displaying the extra field and I'm good to go.
Thank you for your help!