Forum

Thread tagged as: Problem

siteURL in global.header.php

I need the site url set in perch settings in my global.header.php

To make something like: <link href="<?php echo $siteUrl; ?>/static/plugin/bootstrap/css/bootstrap.min.css" rel="stylesheet">

How can I do that?

R Hoogervorst

R Hoogervorst 0 points

  • 2 years ago
Simon Clay

Simon Clay 127 points

Hi, does

<link href="https://<?php $_SERVER['HTTP_HOST'] ?>/static/plugin/bootstrap/css/bootstrap.min.css" rel="stylesheet">

work for you?

Hi Simon,

Thanks for your answer. Your solutions doesn't work for me. I need a solution for my local dev en live site. Local is something like https://localhost/myproject. Your solution wil output "localhost". Was hoping to just use perch settings

Hi

I wouldn't recommend working with Perch in a subfolder. Create a virtualhost to map the folder you want to work in locally to a domain. That way your root stays the same wherever you run the website. Then you don't really need to worry about server paths so much.

There are plenty of ways you can achieve the above. You can use Simon's method, which is perfectly valid, you can use $_SERVER['DOCUMENT_ROOT'] instead to get the full path, you could use relative paths (which is easier), and you could use a Perch Feather.

They are all listed in the docs.

Hope this helps you get sorted.

Jon