Cannot access protected property Concrete\Core\File\File::$fID
Permalink
Hi there,
I want to place a background on my page, comming from an attribute. <5.7 I did it with the following code:
Now I get the error
Cannot access protected property Concrete\Core\File\File::$fID
Does anybody know what to do? Thanks!
I want to place a background on my page, comming from an attribute. <5.7 I did it with the following code:
Now I get the error
Cannot access protected property Concrete\Core\File\File::$fID
Does anybody know what to do? Thanks!
Although, I'm not sure whether you even need that.
Your example does not specifically explain what type of an attribute the 'achterground' is but if it's already a file attribute, the line that says:
is completely unnecessary.
You could use the $pl variable straight away if it's already a File object.
Your example does not specifically explain what type of an attribute the 'achterground' is but if it's already a file attribute, the line that says:
$pv = File::getByID($pl->fID);
is completely unnecessary.
You could use the $pl variable straight away if it's already a File object.
Yes it is a file attribute. 'achtergrond' is dutch for 'background'. The following code is working like a charm:
So thanks a lot!
$pl = $c->getCollectionAttributeValue('achtergrond'); if (empty($pl)) { $image_url = $this->getThemePath()."/images/banner.png"; } else { $image_url = $pl->getRelativePath(); }
So thanks a lot!
AFAIK, you even don't need to define $c (if you're on a theme).
But yeah, mainio is correct. If the page attribute is a file type, then you have the image object already, and you can get the the relative url straight off of it.
But yeah, mainio is correct. If the page attribute is a file type, then you have the image object already, and you can get the the relative url straight off of it.
to: