File Attributes

Permalink
Is it possible to make a File Attribute that is a "URL" open in a new window?

bryanlewis
 
mesuva replied on at Permalink Best Answer Reply
mesuva
I think you may need to go into more detail about what you are after here, but if you are asking can you create a link to a file that opens in a new window, this should be pretty straightforward in a template:

$page = Page::getCurrentPage();
$file = $page->getAttribute('file_attribute_handle');
if($file) {
echo '<a target="_blank" href="' .  $file->getVersion()->getRelativePath() .' ">Download</a>';
}
bryanlewis replied on at Permalink Reply
bryanlewis
I'm sorry I should have explained myself better. I was in a hurry.

I have a File Attribute that I made Called "url" and when I put a link in to Google or another website this attribute works just fine but, its not opening in a new window. It opens in the same window it's already in.

So, I think this code will help I will just need to figure out how to make it work with what I already have.

Thanks for taking the time to respond! Means a lot to me!

b-lew
bryanlewis replied on at Permalink Reply
bryanlewis
That worked great! Thank you!