0

I have been trying to add a channel field where I can allow the user to upload files with ease especially PDF files. I just bought the "Channel Files" module but I cannot get it to work for me. The problem is that I cannot see the files on the page where i'm trying to upload the files. It seems to work perfectly fine on the publishing page and I am able to upload files there. I think I just didn't get the code right on the template.

     <div class="files">
     {exp:channel_files:files channel="news" field="section"}
     <a href="{file:title}">{file:title}</a>
     {/exp:channel_files:files}
     </div>    

2 Answers 2

0

Actually if you are using this within an entry, it is easiest to just use the field name.

{exp:channel:entries channel="whatever" limit="1"}

{my_files_custom_field}
<a href="{file:url}">{file:title}</a>
{/my_files_custom_field}

{/exp:channel:entries}

If that doesn't work and you get empty values for the url and title you are most likely having some variable collision. Most likely you called the channel field "files".

So do this then

{exp:channel:entries channel="whatever" limit="1"}

{my_files_custom_field prefix="cf"}
<a href="{cf:url}">{cf:title}</a>
{/my_files_custom_field}

{/exp:channel:entries}

You will see here I am changing the variable prefix so it doesn't conflict with another variable called "files".

1
  • That worked! you're right, I actually named the channel entries "files" and that what caused the issue. Thank you so much!
    – user3282
    Commented Dec 16, 2014 at 6:16
0

The channel files tag pair displays the files associated with a specific entry, so for troubleshooting purposes, have you tried to remove all of the parameters to see what the tag pair returns? If you do this:

{exp:channel_files:files}
 <a href="{file:url}">{file:title}</a>
{/exp:channel_files:files}

Do you get anything within your template (I'm ignoring for the moment any possibility that you have multiple channel file fields within your channel)?

3
  • I tried that. it didn't work :( I also tried to uninstall the module and re install it. That also didn't work
    – user3282
    Commented Dec 11, 2014 at 15:28
  • When you turn on template debugging, what is revealed about the channel files tag pair? Is there an indication of an error? Or of results are not being found? Commented Dec 11, 2014 at 15:39
  • Yeah it seems that it cannot be found as I see this in Inspect Element: <a href></a> there are no errors, but there is a warning that says "Ignoring get or set of property that has [LenientThis] because the "this" object is incorrect"
    – user3282
    Commented Dec 11, 2014 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.