hi guys, i have 1 extra field type IMAGE.
I would like that when a user insert the image, in the frontend show the image + fancybox effect.
My problem is give the only path of image.. I try with:
I would like that when a user insert the image, in the frontend show the image + fancybox effect.
My problem is give the only path of image.. I try with:
13 years 10 months ago #108815
Just a guess
Look in phpmyadmin and edit an item that has an image for xtra field
determine that only the filename is stored there.
Find the path to the filename
change your code to
<code>
<a class="galleria" data-fancybox-group="gallery" title="<?php K2HelperUtilities::cleanHtml($item->title); ?>" href="<?php echo "PATHNECESSARYTOFINDFILE" . $this->item->extraFields->Image->value; ?>" > <?php echo $custom[5]->value; ?></a>
Look in phpmyadmin and edit an item that has an image for xtra field
determine that only the filename is stored there.
Find the path to the filename
change your code to
<code>
<a class="galleria" data-fancybox-group="gallery" title="<?php K2HelperUtilities::cleanHtml($item->title); ?>" href="<?php echo "PATHNECESSARYTOFINDFILE" . $this->item->extraFields->Image->value; ?>" > <?php echo $custom[5]->value; ?></a>
Topic Author
13 years 10 months ago #108816
Hi William thank you for your answer.
I just see in the table "k2_items" and in the field "extra_fields" this:
I just see in the table "k2_items" and in the field "extra_fields" this:
13 years 9 months ago #108819
is Image the xtrafield alias ?
from blog post 2.6.2
So how would you directly output individual extra fields in your K2 overrides? Simple. Just do something like this (e.g. in item.php) to get the extra field name:
$this->item->extraFields->EXTRAFIELDALIASHERE->name
To get the extra field value you would simply do this:
$this->item->extraFields->EXTRAFIELDALIASHERE->value
Simply replace EXTRAFIELDALIASHERE with the actual alias of the extra field you wish to output.
from blog post 2.6.2
So how would you directly output individual extra fields in your K2 overrides? Simple. Just do something like this (e.g. in item.php) to get the extra field name:
$this->item->extraFields->EXTRAFIELDALIASHERE->name
To get the extra field value you would simply do this:
$this->item->extraFields->EXTRAFIELDALIASHERE->value
Simply replace EXTRAFIELDALIASHERE with the actual alias of the extra field you wish to output.
Topic Author
13 years 9 months ago #108820
i did it but don't works. I try with ->name and ->value but nothing.. in the href there is the value "Image 1" so the link is www.website.it/Image%201 .
Below the code:
Below the code:
13 years 9 months ago #108821
If Admin/User has permision to put PHP code in editor window is it possible to call image field in the middle of Item text / body?
13 years 9 months ago #108823
@andrea
You can use this, or something similar to it to do what you need
<div>
<?php
$var = $this->item->extraFields->Image->value ;
$var = preg_replace('/<img src="/',"",$var);
$var = preg_replace('/" alt="Image" \>/'," ",$var);
echo '<a class="galleria" href="' . $var . "TextOfLink" ."</a>" ;
?>
</div>
You can use this, or something similar to it to do what you need
<div>
<?php
$var = $this->item->extraFields->Image->value ;
$var = preg_replace('/<img src="/',"",$var);
$var = preg_replace('/" alt="Image" \>/'," ",$var);
echo '<a class="galleria" href="' . $var . "TextOfLink" ."</a>" ;
?>
</div>
Log in or create an account to reply.