Page 1 of 1

[SOLVED] File not appearing in news detail template

Posted: Wed Oct 15, 2014 12:03 pm
by chillifish
I've uploaded a file to the news detail template and it's not appearing. I would expect it to appear in the following section of the template:

Code: Select all

{if isset($entry->fields)}
  {foreach from=$entry->fields item='field'}
     <div class="NewsDetailField">
        {if $field->type == 'file'}
	  {* this template assumes that every file uploaded is an image of some sort, because News doesn't distinguish *}
          <img src="{$entry->file_location}/{$field->displayvalue}"/>
        {else}
          {$field->name}:&nbsp;{eval var=$field->displayvalue}
        {/if}
     </div>
  {/foreach}
{/if}
If i put the following code in the template:

Code: Select all

{if $entry->file_location}
	<div id="NewsPostDetailFile">
		<img src="{$entry->file_location}/{$field->displayvalue}" alt="Article image" />
	</div>
{/if}
I get the alt text, but the image location is not completed.

Re: File not appearing in news detail template

Posted: Wed Oct 15, 2014 1:04 pm
by psy
Try {$field->value}

Re: File not appearing in news detail template

Posted: Wed Oct 15, 2014 1:10 pm
by chillifish
I'm afraid that doesn't work either. I'm sure it's got something to do with the way I'm referencing the field value object. What concerns me is that the first option which is actually in the sample template doesn't work, which suggests the module is broken.

Re: File not appearing in news detail template

Posted: Wed Oct 15, 2014 1:13 pm
by psy
Are you using the {foreach} loop for the custom fields or accessing them individually?

Re: File not appearing in news detail template

Posted: Wed Oct 15, 2014 1:22 pm
by chillifish
Acessing them individually, but the foreach loop doesn't work either as can be seen from the first example.

Re: File not appearing in news detail template

Posted: Wed Oct 15, 2014 1:23 pm
by psy
OK, individuallly.

So does:

Code: Select all

<img src="{$entry->file_location}/{$entry->fields.MYIMAGEFIELDNAME->value}"/>
work?

Does your fieldname have a space in it eg 'My Image'? If so, try:

Code: Select all

{$myimage='My Image'}
<img src="{$entry->file_location}/{$entry->fields.$myimage->value}"/>
Really need more info about the field you are trying to access.

Re: File not appearing in news detail template

Posted: Wed Oct 15, 2014 1:43 pm
by chillifish
That doesn't work either.

I have a field with a name of "Image" and a type of "file". In the article, I have browsed for a file and uploaded it. It's on the server when I check with the file browser.

The above News Detail template gives me the location of the enclosing folder, but won't give me the name of the file.

Re: File not appearing in news detail template

Posted: Wed Oct 15, 2014 1:48 pm
by Jo Morg
In CMSMS version 1.11.11 I just tested and it works for me. Are you sure that the field definition is set to public?

Re: File not appearing in news detail template

Posted: Thu Oct 16, 2014 10:31 am
by chillifish
THANKYOU, THANKYOU, THANKYOU.

I hadn't set it to public, DOH.