Faisal Posted October 17, 2015 Share Posted October 17, 2015 Hi I have pages with multi attachment I have field type file with the name files and the Formatted value is Automatic my template file code $content = "<h1>".$page->title."</h1>"; $content .= $page->body; if(count($page->files)) { foreach($page->files as $file) { $attachments = "<a href='$file->url'>$file->name</a><br>"; } } else { $attachments = "No Files!"; } $content .= $attachments; The problem is it only show one file even if there are more than one! Link to comment Share on other sites More sharing options...
tpr Posted October 17, 2015 Share Posted October 17, 2015 You overwrite $attachments in the for each, use ".=". 2 Link to comment Share on other sites More sharing options...
Faisal Posted October 18, 2015 Author Share Posted October 18, 2015 Oops! Thank you it is working now $content = "<h1>".$page->title."</h1>"; $content .= $page->body; if(count($page->files)) { $attachments = ""; foreach($page->files as $file) { $attachments .= "<a href='$file->url'>$file->name</a><br>"; } } else { $attachments .= "No Files!"; } $content .= $attachments; Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now