We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24853
    • 29 Posts
    I must admit I don't understand the concept of TV's completely so maybe it's possible with them but so far I didn't manage to do this. Otherwise it's another entry from me to the wishlist wink

    I'd like to have a possibility to pass parameters from the content itself to the template to be able to modify the template slightly.

    I know I can apply a different template to each page, but as I need only to make really minor modifications (ie. exchange 1 gfx and 1 link) this would totally be an overkill as this would require me too much nearly-the-same templates just for this. I thought about different solutions to my problem, but the easiest one would be if I could pass some value to the php code of the template.

    I don't know anything about the eto rendering internals but I guess technically it wont be too hard to scan the content for specific delimiters ([# #] { } etc. ) and parse them before any code from the template is executed!?


    Example:

    1. content page
    [#set var='val1'#]
    content text

    2. template
    <?php
    if (! $var) { $var='defaultval'; }
    if $var='val1' { echo "1"; } elseif $var='val2' { echo "2"; }
    ?>
      • 32963
      • 1,732 Posts
      Hi

      You can accomplish this using the new placeholder tags [++]

      For example:

      You can add the placeholder tags insde a template [+myimage+]

      Then create a simple snippet that sets the value of the place holder

      $etomite->setPlaceholder("myimage","images/ad.gif");

      Or you could create a TV and set the Input Type TextBox or TextArea (mini). When creating you document you then add the image tag or html he textbox provided.
      This would cause each page to render it's own content for that TV
        xWisdom
        www.xwisdomhtml.com
        The fear of the Lord is the beginning of wisdom:
        MODx Co-Founder - Create and do more with less.
        • 24853
        • 29 Posts
        Cool, that's just want I was looking for ... simple and effective! smiley
        Thanks a lot! laugh

        (maybe this should be moved to some support forum if avaible)
          • 34162
          • 1 Posts
          Xwisdom: That is fantastic! Pure genius. =)

          Is that in v3? I don't recall having seen anything on the [++] syntax before...
            • 24853
            • 29 Posts
            Is that in v3? I don't recall having seen anything on the [++] syntax before...

            it's mentioned in the changelog (at least since, I don't have any previous version) modx2rc1 & modx2rc2


            changelog:
            * add Placeholder Variables to etomite API. usage: [+name+]
            • Hi

              You can accomplish this using the new placeholder tags [++]

              For example:

              You can add the placeholder tags insde a template [+myimage+]

              Then create a simple snippet that sets the value of the place holder

              $etomite->setPlaceholder("myimage","images/ad.gif");

              Or you could create a TV and set the Input Type TextBox or TextArea (mini). When creating you document you then add the image tag or html he textbox provided.
              This would cause each page to render it's own content for that TV

              Wow, I was unaware of these feature as well. Ok, I'm just thinking out loud here, but what if we added the ability for passing template variables (and possibly template objects eventually) as the placeholder values? We may already have the makings of Template Objects with this, simply by adding hierarchical references as the placeholder names and having the Placeholder parser read expressions for the objects.
                • 32963
                • 1,732 Posts
                Xwisdom: That is fantastic! Pure genius. =)

                Is that in v3? I don't recall having seen anything on the [++] syntax before...

                Yes it's there inside the changelog and inside the API quick Reference Guide.

                You can down load MODx2 here http://www.sottwell.com/modx
                  xWisdom
                  www.xwisdomhtml.com
                  The fear of the Lord is the beginning of wisdom:
                  MODx Co-Founder - Create and do more with less.
                  • 32963
                  • 1,732 Posts


                  Wow, I was unaware of these feature as well. Ok, I'm just thinking out loud here, but what if we added the ability for passing template variables (and possibly template objects eventually) as the placeholder values?

                  Sure you can! Just simple use the getTemplateVarOutput function and the setPlaceholder function:

                  $tvout = $etomite->getTemplareVarOutput("myTV");
                  // now set the value of the placeholder
                  $etomite->setPlaceholder("placeholder",$tvout);

                  That's it! smiley

                  Placeholders are very powerful allowing you to add anything anywhere inside the template, document, chunk, etc
                    xWisdom
                    www.xwisdomhtml.com
                    The fear of the Lord is the beginning of wisdom:
                    MODx Co-Founder - Create and do more with less.
                  • Absolutely wonderful:

                    Had no idea, and now my mind is racing at the possibilities. So glad I chose this project over the option of starting my own MOD site for Etomite :wink:

                    My focus on TVO now is shifting as a result of this and more discussion with infoclipper regarding core and external database abstraction...

                    see the posts at this topic http://vertexworks.com/forums/viewtopic.php?t=16