Jump to content

Recommended Posts

Posted

Hi,

for a download area i wanna use a repeater field with a text field (description of that download) and a file field (the download file). 

The repeater field is "downloads" and it contains the fields "body_part_1" and "download_files". When i use this:

<div class="uk-grid">
		<?php foreach($page->downloads as $download): ?>
		<div class="uk-width-4-6">
			<?php echo $download->body_part_1; ?>
		</div>
		<div class="uk-width-2-6">
			<?php $file = $download->download_files;
			if($file) echo "<a class='download-links' href='$file->url'>$file->description</a>";
			?>
		</div>
		<?php endforeach; ?>
	</div>

the output is this:

<div class="uk-width-2-6">
<a class='download-links' href='/site/assets/files/1083/'></a>		
</div>

The text (body_part_1) is ok, but no description inside the link and the path lacks the filename. Of course it's my fault, but what i'm doing wrong?

Posted

Is it a single entry file field? If so, what does $download->of() return? Just in case try this one: 

 $file = $download->download_files->first();
  • Like 2
Posted

Oh my god, i did it again.  What a careless mistake.  :angry: 

It should be a single entry field but the Maximum files allowed was set to 0. Changed it to 1 and everything works like a charm. Thanks for pointing me to the details of the field!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...