Jump to content

Need help with page attacment


Faisal
 Share

Recommended Posts

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

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...