4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
February 09, 2010, 12:54:57 PM

Login with username, password and session length
Search:     Advanced search
Follow 4images on twitter: Click here to follow!
Translate this page with google
=>
 Translate this page with Google =>
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Help / Hilfe
| |-+  Bug Fixes & Patches
| | |-+  [1.7.1] Conditional tags inside other conditional tags + {ifno ...}{endifno ...}
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 » »» Print
Author Topic: [1.7.1] Conditional tags inside other conditional tags + {ifno ...}{endifno ...}  (Read 32973 times)
V@no
Don't tell me what to do and I won't say where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 16729

Thank You
-Given: 13
-Receive: 81

mmm PHP...


View Profile WWW
« on: April 19, 2005, 12:24:19 AM »

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:
1
2
3
4
5
6
    // 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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
    // 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:
1
2
3
  function _compile_condition(&$matches) {
    return '<?php if (!empty($' . trim($matches[1]) . ') && $' . trim($matches[1]) . ' != REPLACE_EMPTY): ?>' . $matches[2] . '<?php endif; ?>';
  }
Replace it with:
1
2
3
4
5
6
7
8
9
10
11
12
  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 Wink
Logged

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)
ashantiforever
Newbie
*
Offline Offline

Posts: 15

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #1 on: May 15, 2005, 08:39:04 PM »

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
Logged
V@no
Don't tell me what to do and I won't say where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 16729

Thank You
-Given: 13
-Receive: 81

mmm PHP...


View Profile WWW
« Reply #2 on: May 15, 2005, 08:44:12 PM »

restore backups and try again.
Logged

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)
ashantiforever
Newbie
*
Offline Offline

Posts: 15

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #3 on: May 15, 2005, 10:05:54 PM »

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 }
Logged
ashantiforever
Newbie
*
Offline Offline

Posts: 15

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #4 on: May 15, 2005, 10:27:46 PM »

nevermind .. I fixed it by uploading a modified "template.php" file from 1.7
Logged
Josef Florian
Newbie
*
Offline Offline

Posts: 27

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #5 on: May 19, 2005, 08:39:53 AM »

Thanks V@no!!!

 Very Happy
Logged

    • running v1.7.6 with MOD: SortImageAsYouLike / Cooliris Slideshow
    • with © removal
    • i have problems with:
    actually no[/list]
    karimun
    Newbie
    *
    Offline Offline

    Posts: 49

    Thank You
    -Given: 0
    -Receive: 0


    View Profile WWW
    « Reply #6 on: June 25, 2005, 11:56:24 PM »

    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.
    Logged
    karimun
    Newbie
    *
    Offline Offline

    Posts: 49

    Thank You
    -Given: 0
    -Receive: 0


    View Profile WWW
    « Reply #7 on: June 26, 2005, 09:06:35 AM »

    Ok, I killed this nasty bug with this fix: http://www.4homepages.de/forum/index.php?topic=6806.0
    Logged
    V@no
    Don't tell me what to do and I won't say where you should go :)
    Administrator
    4images Guru
    *****
    Offline Offline

    Posts: 16729

    Thank You
    -Given: 13
    -Receive: 81

    mmm PHP...


    View Profile WWW
    « Reply #8 on: June 26, 2005, 12:42:30 PM »

    seems to me u have an opening conditional tag (if tag} but without closing one {endif tag} (or opposite)
    Logged

    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)
    maziggy
    Newbie
    *
    Offline Offline

    Posts: 38

    Thank You
    -Given: 0
    -Receive: 0


    View Profile
    « Reply #9 on: June 26, 2005, 12:52:18 PM »

    For me it works. Thanks for that fix Wink
    Logged
    WhiteRabbit
    Newbie
    *
    Offline Offline

    Posts: 29

    Thank You
    -Given: 0
    -Receive: 0


    View Profile
    « Reply #10 on: August 04, 2005, 05:11:45 AM »

    Great work!

    Thanks!.

    Best regards.
    WR.
    Logged
    TXtaholic
    Jr. Member
    **
    Offline Offline

    Posts: 67

    Thank You
    -Given: 0
    -Receive: 0

    life is ours we live it our way!


    View Profile WWW
    « Reply #11 on: November 16, 2005, 12:11:20 PM »

       thanks v@no  Smile  Smile great effort
    Logged

    megalomania
    Newbie
    *
    Offline Offline

    Posts: 13

    Thank You
    -Given: 0
    -Receive: 0


    View Profile
    « Reply #12 on: March 15, 2006, 01:17:32 AM »

    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.  Embarassed

    Greetings, Mega
    Logged
    V@no
    Don't tell me what to do and I won't say where you should go :)
    Administrator
    4images Guru
    *****
    Offline Offline

    Posts: 16729

    Thank You
    -Given: 13
    -Receive: 81

    mmm PHP...


    View Profile WWW
    « Reply #13 on: March 15, 2006, 01:37:10 AM »

    There is nothing needed to be changed, it should work just fine. Or perpahs you should be more describtive then saying "it doesnt work" Wink
    Logged

    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)
    konradin
    Jr. Member
    **
    Offline Offline

    Posts: 75

    Thank You
    -Given: 0
    -Receive: 0


    View Profile WWW
    « Reply #14 on: May 02, 2006, 04:57:54 AM »

    Needs the Version 1.7.2 this Mod/Fix too?

    Thanks, bye Konradin
    Logged

    Pages: [1] 2 » »» Print 
    « previous next »
    Jump to:  

    Powered by MySQL Powered by PHP Powered by SMF | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
    piqs.de - Fotocommunity & lizenzfreie Fotos