Jump to content

page reference not working


webhoes
 Share

Recommended Posts

Hello, I have 2 page type:

Books and reports. A report can be link to a book. There is only 1 document (pdf) in a report.

I can get the list of linked reports on the book page. But I can not get it to give me the download url.

If I use the same field (annual_report) as part of the book template, all works flawlessly. But I need to have the report  as a seperate entity.

Why doesn't this work?

 

 

$reports = '';
foreach ($page->annual_report as $report){

$reports .=  '<a href="' . $report->url . '" class="download-btn" target="_blank"><i class="fa fa-file-pdf-o" aria-hidden="true"></i>' . $report->description . '</a>';

}

//this doensn''t work, but should be correct
$ann = '';
$annual = $pages->find("template=annual-report, studbook=$page->id");
foreach($annual as $a){

    $ann .= '<a href="' . $a->annual_report->url . '" class="download-btn" target="_blank"><i class="fa fa-file-pdf-o" aria-hidden="true"></i>' . $a->annual_report->description . '</a>';

}

 

 

 

Link to comment
Share on other sites

studbook=$page->id

is old...

studbook=$page->title

what I use...

I changed this for one of the tests. I also tried to build up the path to the document with this.

$path = $a->annual_report->url;

$path .= $a->annual_report->name;

$path .= '.' . $a->annual_report->ext;

But also this only shows the directory where the pdf resides. Nothing about the pfd itself.

 

Link to comment
Share on other sites

3 minutes ago, webhoes said:

But also this only shows the directory where the pdf resides. Nothing about the pfd itself.

This means you've set up the file field to give you an array of files (Pagefiles), you need to get the file using annual_report->first->url.
Using annual_report->url gives you the directory.

You can limit field to 1 file and return you a Pagefile object instead of an array (Pagefiles) too

  • Like 2
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...