ravenquork Posted October 27, 2008 Share Posted October 27, 2008 Currently the URL to the sites css file is this: <link rel="stylesheet" media="screen" href="{$insUrl}themes/{$CalendarInfo['css']}" type="text/css" > where $insUrl is a local link. I would like to allow users to optionally link to an external css file. My thinking is to optionally use either the existing URL to a local css file or a user supplied URL to a remotely hosted css file so if I define: $insUrl is the URL to a local themes/local.css file $insUrlcss is the URL to either remote.css or local.css files $insUrlcssremote is the URL to a remotely hosted css file $remotecss is the name of a remote css file {$CalendarInfo['css'] is a local css file Currently I have: href="{$insUrl}themes/{$CalendarInfo['css']}" In English, I would like to first use: href="{$insUrlcssremote}/{$remotecss}" (A link to to a remote css file) But, if remote.css doesn't exist, use the original link href="{$insUrl}themes/{$CalendarInfo['css']}" (A link to to a local css file) My thinking is to use something like href="{$insUrlcss}" First Check if {$remotecss} exists if remote.css exists then use it {$insUrlcss} = {$insUrlcssremote}/{$remotecss} href="{$insUrlcss}" becomes href="{$insUrlcssremote}/{$remotecss}" if $remotecss doesn't exist then fail gracefully to the local.css file insUrlcss = $insUrl}themes/{$CalendarInfo['css'] or in other words href= "{$insUrlcss}" becomes href="{$insUrl}themes/{$CalendarInfo['css']}" Since I am a total noob at php, I need help in actually writing this piece of code Quote Link to comment https://forums.phpfreaks.com/topic/130250-change-url-of-css-file-based-on-file-availablility/ Share on other sites More sharing options...
rhodesa Posted October 27, 2008 Share Posted October 27, 2008 <?php if($remotecss){ $insUrlcss = "{$insUrlcssremote}/{$remotecss}"; }else{ $insUrlcss = "{$insUrl}themes/{$CalendarInfo['css']}"; } ?> <link rel="stylesheet" media="screen" href="{$insUrlcss}" type="text/css" > or shorthand: <link rel="stylesheet" media="screen" href="<?=($remotecss)?"{$insUrlcssremote}/{$remotecss}":"{$insUrl}themes/{$CalendarInfo['css']}"?>" type="text/css" > Quote Link to comment https://forums.phpfreaks.com/topic/130250-change-url-of-css-file-based-on-file-availablility/#findComment-675552 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.