Author Topic: [1.7.1] Conditional tags inside other conditional tags + {ifno ...}{endifno ...}  (Read 62071 times)

0 Members and 1 Guest are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Since v1.7.1 introduced new, optimized template engine, a little bug was created which would not allow use conditional tags inside other conditional tags:
Quote
{if blah}{if blah2}...{endif blah2}{endif blah}
the {if blah2}{endif blah2} would be ignored.
Also, in this fix I added new feature {ifno blah}{endifno blah} type of conditional tags. That condition is opposite of {if blah} meaning that code between these tags will be showed only if {blah} tag is empty.



Open includes/templates.php
Find:
Code: [Select]
// Compile condition tags
$template = preg_replace_callback(
'='.preg_quote($this->start).'if\s+([A-Z0-9_]+)'.preg_quote($this->end).'(.*)'.preg_quote($this->start).'endif\s+(\\1+)'.preg_quote($this->end).'=Usi',
array(&$this, '_compile_condition'),
$template
);
Replace it with:
Code: [Select]
// Compile condition tags
$template = preg_replace_callback(
'='.preg_quote($this->start).'if\s+([A-Z0-9_]+)'.preg_quote($this->end).'=Usi',
array(&$this, '_compile_condition_start'),
$template
);
$template = preg_replace_callback(
'='.preg_quote($this->start).'endif\s+([A-Z0-9_]+)'.preg_quote($this->end).'=Usi',
array(&$this, '_compile_condition_end'),
$template
);
$template = preg_replace_callback(
'='.preg_quote($this->start).'ifno\s+([A-Z0-9_]+)'.preg_quote($this->end).'=Usi',
array(&$this, '_compile_condition_no_start'),
$template
);
$template = preg_replace_callback(
'='.preg_quote($this->start).'endifno\s+([A-Z0-9_]+)'.preg_quote($this->end).'=Usi',
array(&$this, '_compile_condition_no_end'),
$template
);

Then find:
Code: [Select]
function _compile_condition(&$matches) {
return '<?php if (!empty($' . trim($matches[1]) . ') && $' . trim($matches[1]) . ' != REPLACE_EMPTY): ?>' . $matches[2] . '<?php endif; ?>';
}
Replace it with:
Code: [Select]
function _compile_condition_start(&$matches) {
return '<?php if (!empty($' . trim($matches[1]) . ') && $' . trim($matches[1]) . ' != REPLACE_EMPTY){ ?>';
}
function _compile_condition_end(&$matches) {
return '<?php ?>';
}
function _compile_condition_no_start(&$matches) {
return '<?php if (empty($' . trim($matches[1]) . ') || $' . trim($matches[1]) . ' == REPLACE_EMPTY){ ?>';
}
function _compile_condition_no_end(&$matches) {
return '<?php ?>';
}

P.S. if u dont need {ifno ..} feature, then I think it wouldn't be too dificult to figure out what needed to be removed ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline ashantiforever

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • http://www.ashantiforever.tk
Parse error: parse error, unexpected '}' in /home/bphotos/public_html/newsum/includes/template.php(101) : eval()'d code on line 259

For some reason .. it's giving me a parse error when I use that mod. Strange thing is that I don't even have a line 259 in the PHP coding .. it stops at 240-something

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
restore backups and try again.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline ashantiforever

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • http://www.ashantiforever.tk
it's still doing it .. and I did all the steps over (3 times)

It's weird because it's only doing it on pages other than index.php

{ links removed }

Offline ashantiforever

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • http://www.ashantiforever.tk
nevermind .. I fixed it by uploading a modified "template.php" file from 1.7

Offline Josef Florian

  • Newbie
  • *
  • Posts: 27
    • View Profile
Thanks V@no!!!

 :D
    • running v1.7.6 with MOD: SortImageAsYouLike / Cooliris Slideshow
    • with removal
    • i have problems with:
actually no[/list]

Offline karimun

  • Newbie
  • *
  • Posts: 49
    • View Profile
    • http://www.at6pm.com
I also have a similar problem like ashantiforever described it above:
In my case it returns the parse error for index.php ONLY - the other pages seem to work with this MOD.

What more can I try? Thank you.

Offline karimun

  • Newbie
  • *
  • Posts: 49
    • View Profile
    • http://www.at6pm.com
Ok, I killed this nasty bug with this fix: http://www.4homepages.de/forum/index.php?topic=6806.0

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
seems to me u have an opening conditional tag (if tag} but without closing one {endif tag} (or opposite)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline maziggy

  • Newbie
  • *
  • Posts: 38
    • View Profile
For me it works. Thanks for that fix ;-)

Offline WhiteRabbit

  • Newbie
  • *
  • Posts: 29
    • View Profile
Great work!

Thanks!.

Best regards.
WR.

Offline TXtaholic

  • Jr. Member
  • **
  • Posts: 67
  • life is ours we live it our way!
    • View Profile
    • i MMS u
   thanks v@no  :)  :) great effort

Offline megalomania

  • Newbie
  • *
  • Posts: 13
    • View Profile
Hello,

I am using the new 1.72 version of 4images and the {ifno...} blah {endifno...} feature doesn't work anymore, for me.
In the "Changelog.txt" it is mentioned, that the code of the 1.72 release differs from the solution in this forum post.

And since I am not very firm in PHP, it would be very helpful if someone may tell me which lines I have to change, in order to get my  {ifno...} blah {endifno...} feature back.  :oops:

Greetings, Mega

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
There is nothing needed to be changed, it should work just fine. Or perpahs you should be more describtive then saying "it doesnt work" ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline koikonut

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://www.konradin.net
Version 1.7.2
« Reply #14 on: May 02, 2006, 04:57:54 AM »
Needs the Version 1.7.2 this Mod/Fix too?

Thanks, bye Konradin

 

Post your comments here