The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
allow page-specific external CSS
#1
I have some CSS that was very specific to a given page and I didn't want to bother loading for every single page.

I found it difficult to get it into the header portion using the standard UserSpice.

I made this modification, as defined by this patch file. This allows a CSS file with the same name as the current PHP script to be loaded automatically. It also allows for the array $HeaderStyles to be initialized before including header.php and the styles will be included in the <-head->...</-head-> section.

===(snip)===
*** UserSpice41/users/includes/header.php 2016-08-15 15:51:52.791690800 +0200
--- imok/users/includes/header.php 2016-08-15 15:49:49.528667200 +0200
***************
*** 82,92 ****
--- 82,111 ----
<!-- AKA Secondary CSS -->
<link href="<?=$us_url_root?><?=str_replace('../','',$settings->us_css2);?>" rel="stylesheet">

+ <!-- If you are loading xyz.php and a script xyz.css exists, load it !-->
+ <?php
+ $mycss = $us_url_root.'usersc/css/'.basename($_SERVER['PHP_SELF'], '.php').'.css';
+ #echo "mycss=$mycss abs_us_root=$abs_us_root<br />\n";
+ if (file_exists($abs_us_root.$mycss)) {
+ echo "<link href=\"$mycss\" rel=\"stylesheet\">\n";
+ }
+ ?>
+
<!-- Your Custom CSS Goes Here!-->
<link href="<?=$us_url_root?><?=str_replace('../','',$settings->us_css3);?>" rel="stylesheet">

<!-- Custom Fonts -->
<link href="<?=$us_url_root?>users/fonts/css/font-awesome.min.css" rel="stylesheet" type="text/css">
+
+ <!-- Custom inline styles !-->
+ <?php
+ if (@$HeaderStyles) {
+ echo "<style>\n";
+ foreach ((array)$HeaderStyles as $style)
+ echo "$style\n";
+ echo "</style>\n";
+ }
+ ?>
</head>

<body>
===(snip)===
  Reply
#2
I love that idea! That's great!
  Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)