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