Page 1 of 1

Problem with News Module Custom fields

Posted: Tue Oct 16, 2018 3:38 pm
by Sendlingur
I have three custom fields in my news module. They are called image, image2 and image3.

I'm not able to call any of them individually except the 'image' one the other donĀ“t show up if I call them.

this is the code I'm using to call the custom fields

Code: Select all

<img src="{$entry->file_location}/{$entry->fields.image->value}"/>
<img src="{$entry->file_location}/{$entry->fields.image2->value}"/>
<img src="{$entry->file_location}/{$entry->fields.image3->value}"/>
for some reason this code only works for the 'image' custom-field.

Obviously I can see all the three images if I use this loop below.

Code: Select all

{if isset($entry->fields)}
  {foreach from=$entry->fields item='field'}
     <div class="PostImg">
        {if $field->type == 'file'}
     {* this template assumes that every file uploaded is an image of some sort, because News doesn't distinguish *}
          {if isset($field->value) && $field->value}
            <img src="{$entry->file_location}/{$field->value}"/>

But if I want to display the images from the custom field separately I get into troubles as I described above.

Can anyone here hlep me figuring this out.

Re: Problem with News Module Custom fields

Posted: Tue Oct 16, 2018 3:41 pm
by Sendlingur
Nevermind.....I posted for help too soon...

the problem was bad naming :)

I named the custom fields Image2 and Image3 instead of image2 and image3.

my bad....