We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2759
    • 21 Posts
    Hello,
    Newbie Banta needs a little jump start advice from the seasoned.

    Is this possible?....

    What I would like to do is have an area ( Chunk?? , Snippet??, TV??, or?? ) that would change depending on if a user was logged in or a guest.

    For example, say I am selling widgets. If a guest browses to the widgets page, the price displayed would be $9.95. However, if a (any) web user is logged in, then the price would be different, say $7.95 Is this possible? embarrassed

    What would be even cooler is if users could be assigned to groups and, if the ’gold’ group member is logged in, then the price is $7.95. But, if the ’platinum’ group member is logged in, then thier price is $4.95. Of course, if a user is not logged in at all, then the price that is displayed is $9.95

    I am hoping this can be done and that it isn’t too complicated. It will certainly go a long way in teaching me how to get things done with MODx.

    Thanks in advance for any help you can offer!

    __________
    Banta
      • 25663 MODX Staff
      • 12,272 Posts
      Make the price a TV with an @EVAL binding that compares the groups and assigns the price. Should work, anyway.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 2759
        • 21 Posts
        Quote from: rthrash at Jun 29, 2006, 01:26 AM

        Make the price a TV with an @EVAL binding that compares the groups and assigns the price. Should work, anyway.
        Huh? embarrassed

        I have been reading through alot of documentation and I grasp what you are saying but, have not a solid plan on exactly how to do that. Is there some code examples or similar processes that have been documented a little that I could take a look at and try to figure out how to do what you’re suggesting? Sorry to be dense. I WILL get the hang of it. Just need a little bit more info.

        Thanks for your patience
        __________
        Banta
          • 25663 MODX Staff
          • 12,272 Posts
          You might look at how the Login/Logout page name is done on the default demo install, or reference http://modxcms.com/eval-binding.html
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 34017
            • 898 Posts
            Quote from: Banta at Jun 29, 2006, 01:12 AM


            What would be even cooler is if users could be assigned to groups and, if the ’gold’ group member is logged in, then the price is $7.95. But, if the ’platinum’ group member is logged in, then thier price is $4.95. Of course, if a user is not logged in at all, then the price that is displayed is $9.95


            Banta,

            It’s me again! For this you might use, as an example:

            Template Variable (name - tvDifferentPrices) (type - @eval)
            <?php if
            usergroup == Gold then $price = 7.95
            elseif
            usergroup == Platinum then $price = 4.95
            else
            $price = 9.95

            return $price
            ?>
            (This code is not marked up right)

            Then in your template or content, you would place [*tvDifferentPrices)*]. Of course you would need to find out the real usergroups etc. But something like this should do the trick.

            Chuck
              Chuck the Trukk
              ProWebscape.com :: Nashville-WebDesign.com
              - - - - - - - -
              What are TV's? Here's some info below.
              http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
              http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
              • 6726
              • 7,075 Posts
              Nice Chuck !

              Banta : one source of inspiration for this could be the Personalize and the MemberCheck snippet (distributed with MODx)
                .: COO - Commerce Guys - Community Driven Innovation :.


                MODx est l&#39;outil id
                • 2759
                • 21 Posts
                Thank You SO much for a push in the right direction.
                So easy to do! I am modifying the the LoginName TV to provide an easy way to change price based on login/logout. Also, updating the @eval from the front end is easy to do. Cool!

                For specific user groups (gold,platinum,etc..), I used the membercheck snippet to display different chunks.  I am going to try now to nest the TV inside a chunk or, a snippet, or whatever I am trying to do here. LOL  Assuming that the nesting will work.  Will it? Any tips?  I need to be able to update the prices from the front end.

                This leads me to another question that I would like some guidance on. Here’s the scenario.

                I use the modified LoginName TV now called WidgetPrice. Instead of @eval code returning Login/Logout text, I just put in value for the price. When I use the quickedit feature, I can edit the parameters from the front end. Now, say I have 2 pages, one for Big Widgets, and one for Small widgets. I use the WidgetPrice TV on each page.  My question is, will updating the values on the Big Widgets page be independent from the values modified on the Small Widgets page?

                In other words, can I create one single WidgetPrice TV and have the changes to the @eval code only modify that page, independent of the other page instances on WidgetPrice TV?  What I am getting at is I would like to have a single TV that is reusable on separate pages, but the values could be different.  Big widgets are $12.95 for logged in users, while Small Widgets are $8.95.?

                I hope this makes sense. It seems kinda confusing now that I am reading it through.  Your advice is going a long way in getting me up to speed  with MODx. I am loving it and am grateful to all those who have helped me out.
                Thanks

                __________
                Banta
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  TVs are edited on a per-document basis, and any change you make for one document will only affect that document (unless you are using @INHERIT bindings, anyway).

                  I have found that often the best way to find out how something works it to just try it, then figure out why it did what it did. After a while, the whole thing begins to become familiar in a way that asking, and getting specific answers to a specific question just can’t match.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 2759
                    • 21 Posts
                    True Dat.

                    You answered the basics for me and that is what I needed to know.

                    I am amazed and floored at the speed of the support on this forum. I hope that I can contribute something.

                    Thank you for your guidance

                    _________
                    Banta
                      • 18397
                      • 3,250 Posts
                      You could also use my TV Conditional snippet. (In the repository)