[pmwiki-users] if exists conditional markup problem

Criss Ittermann crisses at kinhost.org
Thu Apr 2 14:52:57 CDT 2015


Thank you Peter, John -- Much appreciated.  I have it working now.   Changing the markup expression to a page variable worked.

Crisses


> On Apr 2, 2015, at 7:25 AM, Peter Bowers <pbowers at pobox.com> wrote:
> 
> Try turning on diagnostics and then loading with ?action=ruleset.
> 
> Confirm that the rule '{$Var}' occurs before the rule 'if'.
> 
> Confirm that the rule '{(' occurs before '{$Var}' -- oops! I just checked it on my own system and '{$Var}' occurs before '{('. This will mean that the variable-substitution will be attempted before you have created the variable name using your markup expression. Of course the difficulty is that often markup expressions use variables and so you wouldn't really want to swap the order.  You may want to implement my '{earlymx(' rule that I have in WikiSh.php.  The markup itself is about as ugly as I think could be invented, but it will solve your problem. Other, more elegant, solutions will hopefully be suggested by others.
> 
> -Peter
> 
> On Thu, Apr 2, 2015 at 11:51 AM, Criss Ittermann <crisses at kinhost.org <mailto:crisses at kinhost.org>> wrote:
> Thank you, it spits out:
> 
> (:if exists Profile-Data.{Members/Hosts$:201504} :) [...] (:else:) [...] (:if:)
> 
> So the PTV does not appear to have been processed yet -- the markup expression has, though.  And this goes for ALL the PTVs throughout the entire IF condition, including the ones I've redacted with [...]
> 
> However this violates documentation:
> 
> Use page text variables in conditional markup <http://www.pmwiki.org/wiki/PmWiki/ConditionalMarkup>
> Page text variables will be assigned/evaluated before any conditional markup is evaluated. This effectively means that you cannot declare a PTV within an if...else condition; and also that a PTV will have a value even if it is set within a (:if false:)....(:if:) condition.
> 
> on page
> http://www.pmwiki.org/wiki/PmWiki/PageTextVariables <http://www.pmwiki.org/wiki/PmWiki/PageTextVariables>
> 
> I upgraded to the latest version and it still doesn't work.  I turned off each recipe and commented out sections of code that even vaguely might affect conditional processing or PTV evaluation one at a time (it's a live site), and no change.  I did not comment out authentication, captcha or PmForm, since these would break the site in a very bad way and are released by PM & Petko.
> 
> Just for giggles, to take the complexity out of the if-conditional, I even tried:
> 
> TempVar:Profile-Data.{Members/Hosts$:{(ftime "%Y%m")}}
> 
> (:if exists {$:TempVar} :)
> 
> But of course, that failed too.  But the variable itself is set correctly.
> 
> This fails too, whether I use the full expression, or the new variable:
> 
> (:if equal "{$:TempVar}" "Profile-Data.HEdelman" :)  
> revealing the if conditional before it processes:
> (:if equal "Profile-Data.{Members/Hosts$:201504}" "Profile-Data.HEdelman" :)
> 
> 
> (:if false:)
> TempVar:Profile-Data.{Members/Hosts$:{(ftime "%Y%m")}}
> (:if:)
> 
> Still sets the variable.
> 
>> On Apr 1, 2015, at 8:25 PM, John Rankin <john.rankin at affinity.co.nz <mailto:john.rankin at affinity.co.nz>> wrote:
>> 
>> It may be possible to intercept the if code and find out what condition pmwiki is evaluating, which should give information about what is happening. Try this in local/config.php:
>> 
>> $CondTextReplacement = "MyTempRepl(\$pagename, \$m[0], \$m[1])";
>> function MyTempRepl($pagename, $text, $code='') {
>>   echo $text;
>>   return CondText2($pagename, $text, $code);
>> }
>> 
>> If I am reading stdmarkup.php correctly, this should echo the contents of the if code at the time the conditional is evaluated, which will show whether the var has been evaluated as intended.
>> 
>> JR
>> 
>> On 2/04/15 12:07 AM, Criss Ittermann wrote:
>>> I'm trying to figure out why this is returning false ("To be announced."):
>>> 
>>> (:if exists Profile-Data.{Members/Hosts$:{(ftime "%Y%m")}} :)
>>> ...
>>> (:else:)
>>> To be announced.
>>> (:ifend:)
>>> 
>>> 
>>> When the following returns a fully functioning link to the correct page, which exists:
>>> 
>>> [[Profile-Data.{Members/Hosts$:{(ftime "%Y%m")}}]]
>>> 
>>> 
>>> What am I doing wrong?
>>> 
>>> Crisses
>>> 
>>> 
>>> 
>>> _______________________________________________
>>> pmwiki-users mailing list
>>> pmwiki-users at pmichaud.com <mailto:pmwiki-users at pmichaud.com>
>>> http://www.pmichaud.com/mailman/listinfo/pmwiki-users <http://www.pmichaud.com/mailman/listinfo/pmwiki-users>
>> 
>> -- 
>> John Rankin
>> Affinity Limited
>> T +64 4 495 3737 <tel:%2B64%204%20495%203737>
>> M +64 21 726 546 <tel:%2B64%2021%20726%20546>_______________________________________________
>> pmwiki-users mailing list
>> pmwiki-users at pmichaud.com <mailto:pmwiki-users at pmichaud.com>
>> http://www.pmichaud.com/mailman/listinfo/pmwiki-users <http://www.pmichaud.com/mailman/listinfo/pmwiki-users>
> 
> 
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com <mailto:pmwiki-users at pmichaud.com>
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users <http://www.pmichaud.com/mailman/listinfo/pmwiki-users>
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20150402/a6fab9e5/attachment-0001.html>


More information about the pmwiki-users mailing list