[pmwiki-users] Conditional markup with multi-line page variables
Kathryn Andersen
kat_lists at katspace.homelinux.org
Tue Jul 1 19:23:31 CDT 2008
On Mon, Jun 30, 2008 at 06:09:43PM +0100, Andrew Thompson wrote:
> Perhaps I'm doing something stupid, but I've tried lots of variations,
> so this is possibly a bug.
>
> My aim is to display the contents of a variable, with appropriate
> headings, only when the variable is set. If the variable has a
> single-line value, everything works perfectly, eg:
I solved this problem for myself in a different way, by making a
'notnull' condition, which works for multi-line variables as well as
single-line variables.
Added to local/config.php
---------------------------------------------------------------
# Provide notnull conditional
# (:if notnull $Var:)
# (:if notnull $Var PageName:)
$Conditions['notnull'] = 'NotNullCondition($pagename, $condparm)';
function NotNullCondition($pagename, $arg) {
$arg = ParseArgs($arg);
$varname = @$arg[''][0];
if (@$arg[''][1]) // pagename
{
$pagename = $arg[''][1];
}
$val = PageVar($pagename, $varname);
if ($val)
{
return true;
}
return false;
}
---------------------------------------------------------------
Kathryn Andersen
--
_--_|\ | Kathryn Andersen <http://www.katspace.com>
/ \ |
\_.--.*/ | GenFicCrit mailing list <http://www.katspace.com/gen_fic_crit/>
v |
------------| Melbourne -> Victoria -> Australia -> Southern Hemisphere
Maranatha! | -> Earth -> Sol -> Milky Way Galaxy -> Universe
More information about the pmwiki-users
mailing list