[SOLVED] custom display of images

More
9 years 7 months ago #53420 by agata
Replied by agata on topic custom display of images
Hi again,
thanks for this. With my very limited knowledge of php I came up with this:
Code:
<ul class="hotel-carousel__items list-bare js-hotel-carousel"> <?php FlexicontentFields::getFieldDisplay($item, "field_slideshow"); $field_id = 36; $fvals = $item->fieldvalues[$field_id]; $img = $item->fields['field_slideshow']->thumbs_src['large']; if (!empty($fvals)) foreach ($fvals as $v) { if ( @unserialize($v)!== false || $v=== 'b:0;' ) $v = unserialize($v); echo '<li class="hotel-carousel__item"><img src="l_'.$v['originalname'].'" '; echo 'alt="'.$v['alt'].'" class="hotel-carousel__img"></li>'; } ?> </ul>

What this code lacks is the full path to each image.

What I also tried is this:
Code:
<ul class="hotel-carousel__items list-bare js-hotel-carousel"> <?php FlexicontentFields::getFieldDisplay($item, "field_slideshow"); $field_id = 36; $fvals = $item->fieldvalues[$field_id]; $img = $item->fields['field_slideshow']->thumbs_src['large']; if (!empty($fvals)) foreach ($fvals as $v) { if ( @unserialize($v)!== false || $v=== 'b:0;' ) $v = unserialize($v); foreach ($item->fields['field_slideshow']->thumbs_src['large'] as $img) : echo '<li class="hotel-carousel__item"><img src="'.$img.'" alt="'.$v['alt'].'" class="hotel-carousel__img"></li>'; endforeach; } ?> </ul>

But for each alt attribute I get the entire set of images (instead of 7 images with 7 different alt attributes I get 7 images with the first alt, then 7 with the second alt, etc).

Could you provide some assistance with this? I'm in serious php pain right now...
Thanks,
Agata

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

More
9 years 7 months ago #53446 by ggppdk
Replied by ggppdk on topic custom display of images
Hello

you have 2 arrays and 1 array

-- so try using 1 index e.g. $nn to access both


example (not tested)
Code:
FlexicontentFields::getFieldDisplay($item, "field_slideshow"); $field_id = 36; $fvals = $item->fieldvalues[$field_id]; $thumbs = $item->fields['field_slideshow']->thumbs_src['large']; if (!empty($fvals)) for($nn=0; $nn < $fvals.length; $nn++) { $v = $fvals[$nn]; if ( @unserialize($v)!== false || $v=== 'b:0;' ) $v = unserialize($v); $thumb = $thumbs[$nn]; echo '<img src="'.$thumb.'" alt='.$v[alt].'"' />'; }


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

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

More
8 years 9 months ago - 8 years 9 months ago #60090 by agata
Replied by agata on topic custom display of images
Hi,
I'm trying to do the same within the flexicontent universal content module but I'm not getting the alt atribute, it's as though there was nothing in the $item->fieldvalues. My code is:
Code:
<?php FlexicontentFields::getFieldDisplay($item, "field_dest_gallery"); $field_id = 72; $fvals = $item->fieldvalues[$field_id]; $slideshow = $item->fields['field_dest_gallery']; $thumbs = $slideshow->thumbs_src['large']; for ($i = 0; $i < count($thumbs); $i++) : $v = JArrayHelper::getValue($fvals, $i); if ( @unserialize($v)!== false || $v=== 'b:0;' ) $v = unserialize($v); ?> <img src="<?php echo $thumbs[$i]; ?>" alt="<?php echo $v['alt']; ?>" /> <?php endfor; ?>

I am getting Notice: Undefined property: stdClass::$fieldvalues

Any help greatly apreciated.
Agata
Last edit: 8 years 9 months ago by agata.

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

More
8 years 9 months ago #60171 by agata
Replied by agata on topic custom display of images
Hi, any ideas on how to resolve this?
Agata

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

More
8 years 9 months ago #60222 by ggppdk
Replied by ggppdk on topic custom display of images
Hello

for universal module the actual content item are in:
...->_row
did you print

so inside the universal module template if the current content object is named "$item"
then use:
$item->_row->fieldvalues


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...
The following user(s) said Thank You: agata

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

More
8 years 9 months ago #60230 by agata
Replied by agata on topic custom display of images
It took me 2 days trying to unsuccessfully figure it out! Thanks, as ever.
Agata

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.453 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline