Problem with News Module Custom fields

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
Sendlingur
Forum Members
Forum Members
Posts: 61
Joined: Wed Aug 08, 2018 4:59 pm

Problem with News Module Custom fields

Post 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}"/>
          {/if}
        {else}
          {$field->name}:&nbsp;{$field->value}
        {/if}
     </div>
  {/foreach}
{/if}

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.
Sendlingur
Forum Members
Forum Members
Posts: 61
Joined: Wed Aug 08, 2018 4:59 pm

Re: Problem with News Module Custom fields

Post 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....
Locked

Return to “Modules/Add-Ons”