01310: Loading 'Name' css/js/php

Summary: Loading 'Name' css/js/php
Created: 2013-02-17 04:05
Status: Open
Category: Feature
From: VKrishn
Assigned:
Priority: 44
Version:
OS:

Description:

I often need to load css,js,php files based on "Name". Would be nice if PmWiki does it by default.

Code eg.


SDV($PageCSSListFmt,array(
  'pub/css/local.css' => '$PubDirUrl/css/local.css',
  'pub/css/{$Group}.css' => '$PubDirUrl/css/{$Group}.css',
  'pub/css/_{$Name}.css' => '$PubDirUrl/css/_{$Name}.css',
  'pub/css/{$FullName}.css' => '$PubDirUrl/css/{$FullName}.css'
));
foreach((array)$PageCSSListFmt as $k=>$v) 
  if (file_exists($f = FmtPageName($k,$pagename))) 
    $HTMLHeaderFmt[$f] = "\n<link rel='stylesheet' type='text/css' href='$v' />";

Similarly for js and php files if possible.
VKrishn February 17, 2013, at 04:09 AM


Example where I use (for all RecentChanges pages), the css below formats them in tabular like fashion and allows avtar to be added, based on author name.


#wikitext ul { margin: 0px; padding: 0px; }
#wikitext li {
  list-style: none; margin: 0px; padding: 0px;
  text-align: right; font-size: smaller;
}
#wikitext li { border-bottom: 1px dotted #ddd; }
#wikitext li a:first-child { float: left; text-decoration: none; padding-left: 15px; }
#wikitext li a + a[href$=VKrishn] { 
  padding-left: 24px; background: url(/Profiles/VKrishn.gif) center left no-repeat; }

VKrishn February 17, 2013, at 04:09 AM

The CSS loading is already possible, just define the full $PageCSSListFmt array in config.php. About the PHP and JS files this should probably be done as a recipe, and see if people really need it and use it. --Petko February 17, 2013, at 07:50 AM

Would be nice if PmWiki does this, I guess its by adding following in scripts/skins.php 'pub/css/_{$Name}.css' => '$PubDirUrl/css/_{$Name}.css'
Having similar for js maybe a todo recipe, but for php I think still can be a core candidate.
VKrishn February 17, 2013, at 08:18 AM
Array
(
    [post_max_size] => 64M
    [$_POST keys] => 
    [$_REQUEST keys] => n
    [$_SERVER] => Array
        (
            [CONTEXT_DOCUMENT_ROOT] => /home/pmwiki/public_html
            [CONTEXT_PREFIX] => 
            [DOCUMENT_ROOT] => /home/pmwiki/public_html
            [GATEWAY_INTERFACE] => CGI/1.1
            [HTTPS] => on
            [HTTP_ACCEPT] => */*
            [HTTP_ACCEPT_ENCODING] => gzip, br, zstd, deflate
            [HTTP_COOKIE] => imstime=1777545735; PHPSESSID=j5mhhjpum8d56fttr9bc4vd604
            [HTTP_HOST] => www.pmwiki.org
            [HTTP_USER_AGENT] => Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
            [HTTP_X_HTTPS] => 1
            [PATH] => /bin:/usr/bin
            [PHP_INI_SCAN_DIR] => /opt/cpanel/ea-php70/root/etc:/opt/cpanel/ea-php70/root/etc/php.d:.
            [QUERY_STRING] => n=PITS%2f01310
            [REDIRECT_HTTPS] => on
            [REDIRECT_QUERY_STRING] => n=PITS%2f01310
            [REDIRECT_SCRIPT_URI] => https://www.pmwiki.org/wiki/PITS/01310
            [REDIRECT_SCRIPT_URL] => /wiki/PITS/01310
            [REDIRECT_SSL_TLS_SNI] => www.pmwiki.org
            [REDIRECT_STATUS] => 200
            [REDIRECT_UNIQUE_ID] => afMyKRgB5pPrXsTC33nbYAAAAUU
            [REDIRECT_URL] => /wiki/PITS/01310
            [REMOTE_ADDR] => 216.73.216.25
            [REMOTE_PORT] => 54331
            [REQUEST_METHOD] => GET
            [REQUEST_SCHEME] => https
            [REQUEST_URI] => /wiki/PITS/01310
            [SCRIPT_FILENAME] => /home/pmwiki/public_html/index.php
            [SCRIPT_NAME] => /index.php
            [SCRIPT_URI] => https://www.pmwiki.org/wiki/PITS/01310
            [SCRIPT_URL] => /wiki/PITS/01310
            [SERVER_ADDR] => 23.254.203.248
            [SERVER_ADMIN] => webmaster@pmwiki.org
            [SERVER_NAME] => www.pmwiki.org
            [SERVER_PORT] => 443
            [SERVER_PROTOCOL] => HTTP/1.1
            [SERVER_SIGNATURE] => 
            [SERVER_SOFTWARE] => Apache
            [SSL_TLS_SNI] => www.pmwiki.org
            [TZ] => America/Los_Angeles
            [UNIQUE_ID] => afMyKRgB5pPrXsTC33nbYAAAAUU
            [PHP_SELF] => /index.php
            [REQUEST_TIME_FLOAT] => 1777545769.8785
            [REQUEST_TIME] => 1777545769
            [argv] => Array
                (
                    [0] => n=PITS%2f01310
                )

            [argc] => 1
        )

)