Menu

#3 Unhiding SET blocks when parsing them manually

open
5
2003-08-19
2003-08-18
No

Is it possible to parse also set functions, but only
manual? So they won't appear normally but only when
you parse them manually.

Now you've to create an empty block and replace the
item.

Discussion

  • Vincent Driessen

    • summary: parse [set] tags to browser --> Hiding block contents from output
     
  • Vincent Driessen

    Logged In: YES
    user_id=808324

    We're planning to do this with a hide() function that can
    hide blocks from the output. It's on our TODO list now.

    BTW: I've changed your subject a bit, so it's clearer what
    this feature request is about.

     
  • Vincent Driessen

    • status: open --> closed
     
  • Vincent Driessen

    Logged In: YES
    user_id=808324

    Added a hide() function in release 2.13b2. See the online
    documentation for more information.

     
  • Nobody/Anonymous

    Logged In: NO

    Vincent: that's not exactly what i meant. My idea was to let
    the parse function also parse set blocks. So the are not
    automatically parsed but only when you do something like:
    [SET theblock]
    content
    [END theblock]

    if you do:
    $tpl->parse('theblock');

    you'll see content, but if you don't parse it won't appear.
    Do you understand the idea?

     
  • Vincent Driessen

    • status: closed --> open
     
  • Vincent Driessen

    Logged In: YES
    user_id=808324

    Reopened the feature request.

     
  • Vincent Driessen

    • summary: Hiding block contents from output --> Unhiding SET blocks when parsing them manually
     
  • Vincent Driessen

    Yapter 2.12 + added feature

     
  • Vincent Driessen

    Logged In: YES
    user_id=808324

    Arjan wrote:
    I noticed this request in the tracker. I actually added
    this feature myself because i needed it. It was based on
    Yapter v2.12 though. All changed are documented at
    the top of the file. I hope this helps, it's a quite simple
    solution (i only changed 3 lines of code).

    - Arjen

     
  • Nobody/Anonymous

    Logged In: NO

    I dloaded 2.13b yesterday. I waited so long because this
    feature still isn't implemented. Anyway, i needed it again, so i
    thought let's put it in again...
    But i came up with another, far more simple and elegant
    solution!! I only added 1 line of code, and changed a obvious
    one. I will put the solution below, and explain

    Change line 175 to:
    if ($j == $currblockstart && ($currblocktype == "BLOCK" ||
    $currblocktype == "SET")) {

    Then add this line (176) right below that:
    if ($currblocktype == "SET") $this->blox[$currblockname]
    ["parsed"] = array("");

    What happens:
    SET blocks are now identical to BLOCK blocks. However, when
    the parse() function stumbles upon a block, it used to check
    if it was parsed. If it was parsed, it continued, else it called
    the recursive parse function on that block.
    The SET blocks now have a default parsed value of "", so if
    the parse function stumbles upon a SET block, it will think it
    was parsed, and continue, adding "" to the output. If a user
    parses it manually the actual content of the block will be
    parsed, and shown.

    I hope it's clear, it's not at all that difficult :)

    - Arjen

     
  • Nobody/Anonymous

    Logged In: NO

    I have found an elegant and simple solution. First of all, how
    does the parse() function actually work:
    If it stumbles upon a block, it will check if it has been parsed
    ($blox[$blockname]["parsed"]) has a value. If NOT it will call
    the recursive parse call on the block, if YES it will add the
    parsed data to the content and continue.

    I simply changed line 175 and added line 175:

    175: if ($j == $currblockstart && ($currblocktype == "BLOCK"
    || $currblocktype == "SET")) {
    176: if ($currblocktype == "SET") $this->blox
    [$currblockname]["parsed"] = array("");

    Once the parse function stumbles upon this block it will think
    it has been parsed before, and adds ("") to the content. If
    you parse it manually it will actually work like a normal block.
    I hope it is clear, it isn't that complicated. B)

    Enjoy,

    - Arjen

     
  • Nobody/Anonymous

    Logged In: NO

    Note that the clear function should be altered otherwise we
    are getting problems:
    Currently when you clear() a block it sets the parsed data to
    a null-string (""). Whenever the parse() function is called and
    stumbles upon this block it will parse it. We don't want that
    with SET-blocks, and honoustly, i can't figure out why anyone
    would want that otherwise.

    change:
    $this->blox[$blockname]["parsed"] = "";
    in the clear() function to:
    $this->blox[$blockname]["parsed"] = array("");

    (if i remember this above code correctly, but i think i'm
    getting my points across)

    Good luck,
    - Arjen

     

Log in to post a comment.

MongoDB Logo MongoDB