Skip to content

Latest commit

 

History

History
57 lines (40 loc) · 1.69 KB

instance-file-url.md

File metadata and controls

57 lines (40 loc) · 1.69 KB

R2D2::eject()->fileUrl()

Docs | ◄ Prev instance->fileContent() | ► Next instance->htmlOpenTag()


Generate file URL

R2D2::eject()->fileUrl($url, $timestamp = false, $absolute = false) string

Parameters:

Name Data type Default value Description
$url string file relative url, from site root, e.q /assets/css/my.css
$timestamp boolean false set file versioning with query pair ?time=xxx, if file doesn't exist - query will be empty string
$absolute boolean false generate absolute url, with protocol and host setting (see #setup section)

Returns: URL

Usage example

<?php
 
use WezomAgency\R2D2;

// in core app file:
// R2D2::eject()
//       ->set('host', 'my-site.com')
//       ->set('protocol', 'https://')

?>
<link rel="stylesheet" href="<?= R2D2::eject()->fileUrl('/assets/css/style1.css'); ?>">
<link rel="stylesheet" href="<?= R2D2::eject()->fileUrl('/assets/css/style2.css', true); ?>">
<link rel="stylesheet" href="<?= R2D2::eject()->fileUrl('/assets/css/style3.css', true, true); ?>">

Result

<link rel="stylesheet" href="/assets/css/style1.css">
<link rel="stylesheet" href="/assets/css/style2.css?time=1545054627">
<link rel="stylesheet" href="https://my-site.com/assets/css/style3.css?time=1545054627">

Docs | ▲ Top | ◄ Prev instance->fileContent() | ► Next instance->htmlOpenTag()