We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31955
    • 84 Posts
    I may be misunderstanding something, but to me it seems there are contradictiions in the (ModX Revo) documentation on Resource Fields (like "editedon") and Output Filters (like date, for: editeon:date=`...`).

    in the resource fields documentation it is stated that

    Resource fields can be accessed from anywhere by using the Template Variable syntax, ie:
    [[*createdby]]

    whereas in the output filters documentation the examples use a + :

    [[+birthyear:date=`%Y`]]
    which according to the tag documentation is to be used for placeholders, not template variables.

    Are all these * and + interchangeable?

    (my context: [[*editedon:date=`%A, %e %B %Y`]], which btw didn’t seem to work except with the fuzzydate-filter, but [[*editedon:strtotime:date=`%A, %e %B %Y`]] does work.)
    • Indeed the [[+name]] syntax refers to placeholders, and [[*editedon]] refers to resource fields.

      The difference in the use lies in where you are using them.

      Typically, you would be using the resource field tag in templates, and static chunks to display information about the current resource.

      Placeholders are set via a snippet with certain data the snippet wants it to have. While using getResources for example, you will be using the placeholder syntax in the row template chunks which are being set to the value of the resource it is currently retrieving - and that chunk is being repeated many times, with different values in the placeholders.

      Does that clear it up?



      Sorry for the late response, this forum isn’t the most active one it seems tongue
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 31955
        • 84 Posts
        thank you for the response!

        I’m not yet getting it, maybe because I have not enough experience with all this.

        if we stick to another example in the documentation: "createdon". this is mentioned both on the page "resource fields" AND on the page "input & output filters".

        the resources then give examples with the * syntax, while the filter page uses +

        what values would [[+createdon]] give me, an what [[*createdon]] ?
        • You’ll use them in two completely different situations. Ideally, the output is the same when you’ve used both of the syntax in the right situation.


          In your template, you will use [[*createdon:date=`%Y`]] to output the year a resource was published. This tag is placed in the resource directly - and therefore uses the [[*resourcefield]] syntax..

          When you are using a snippet, for example getResources, you will most likely want to modify what the output looks like, so you specify a property in the snippet call called "tpl", and pass the name of a chunk (for example "listingtpl") as its value. Your call could look like this: [[getResources? &tpl=`listingtpl` &parents=`1,3` &limit=`5`]]. Now what the snippet does (to put it real simple) is get a list of 5 resources (&limit=`5`) that match your criteria (it’s a child resource of resource 1 or 3).
          When it has the data, it will start going through them, and output them using your chunk. To give you control over what shows up you made the chunk, which may look like this:
          [[+pagetitle]] was created in the year [[+createdon:date=`%Y`]]

          You will notice the placeholder syntax: it uses [[+createdon]] here, with the date filter. When the snippet (getResources) outputs your chunk, it will specify the value of the placeholders (so every time it outputs a chunk, for each resource being listed, it gives a value to the placeholders). Or to put it differently: your placeholder tag ([[+createdon]]) will be replaced with the value the snippet assigns it at that moment.


          So it’s all about where you can use it. Resource fields need to be directly on a resource (in the template, in a content field or even in a chunk called in a template or content field) where as you can only use placeholder tags when they have been set by a snippet - usually by specifying the chunk in the snippet call, which the snippet uses to output the requested information.
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
            • 3749
            • 24,544 Posts
            FWIW, the correct term for them is "output modifiers." There’s only one output filter, which can process all the different modifiers. I’ve edited the documentation page to try to make that clearer.

            The section on caching that confused you shouldn’t really be on that page at all. It doesn’t seem to have anything to do with output modifiers. I’d remove it, but it should go somewhere and I don’t know where to put it.

            Note that, in theory, the output modifiers can be used with any MODx tag.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 14372
              • 49 Posts
              Anyone with ideas as to why an output modifier would not work ... or rather not display anything? (blank)

              I set the date (dob) in the backend (user manager) and called it like this (gave me a blank result on the front-end)

              [[+dob:date=`%a %b %e, %Y`]]


              And when I call this (with the exclamation mark)

              [[!+dob:date=`%a %b %e, %Y`]]


              it displays.

              My snippet call is ...

              [[!UpdateProfile?
                &preHooks=`formatDobInput`
              ]]


              The format date prehook simply takes in dob input from a datepicker and converts it to a timestamp.

              I also have another problem where the date disappears when I edit/submit another form on the same page ... anyone with ideas about this?
              • In the case where it will not work, you will see that your snippet is called uncached ( [[! ]] ) where as you were caching your placeholder ( [[+ ]] ). The way parsing works is that it first goes through all cached objects and replaces it with its value (or even better: it already did that when the cache was written). Only after that it will parse the uncached snippet.

                Calling both the snippet and placeholder uncached is the way to go in this case.
                  Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                  Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                  • 14372
                  • 49 Posts
                  Ok ... it works with the ’!’ so that’s what I’ve been using ... thanks for the explanation. It has helped understand things a little more.

                  I have a page with many fields (in forms) and I put a submit button for each field instead of having the user fill all the fields then submit all at once. (see code below) And I have just ONE updateprofile snippet call ... because each form button is within <form> html tags so I assume that the button only updates the fields that are in that form in which the button contains.

                  Problem is that when I update another field its only the DOB field that is emptied ... please note that other fields are not affected JUST the dob.

                  I have a prehook that formatts the input from a datepicker into a timestamp ... lemme put some of the code below

                  My snippet call

                  [[!UpdateProfile?
                    &preHooks=`formatDobInput`
                  ]]


                  Examples of two form on the same page ... (I did this to allow the user submit one field at a time instead of the whole form)

                    
                    <!-- update-box: [+dob] format: d-m-Y -->
                    <div class="update-profile" id="dob">
                      <div class="updprof-error">[[+error.message]]</div>
                      <form class="form lb_form" action="[[~[[*id]]]]" method="post">
                        <input type="hidden" name="nospam:blank" value="" />
                        <label for="dob">Date Of Birth (d-m-Y): <span>*</span> </label>
                        <input type="text" name="dob" value="[[!+dob:date=`%a %b %e, %Y`]]" id="datepicker"/>
                        <input class="btn" type="submit" name="login-updprof-btn" value="[[!%login.update_profile]]" />
                      </form>
                    </div>
                  
                    <!-- update-box: [+mobilephone] -->
                    <div class="update-profile" id="telephone">
                      <div class="updprof-error">[[+error.message]]</div>
                      <form class="form lb_form" action="[[~[[*id]]]]" method="post">
                        <input type="hidden" name="nospam:blank" value="" />
                        <label for="mobilephone">[[!%login.mobilephone]] <span class="error">[[+error.mobilephone]]</span> </label>
                        <input type="text" name="mobilephone" value="[[+mobilephone]]" />
                        <input class="btn" type="submit" name="login-updprof-btn" value="[[!%login.update_profile]]" />
                      </form>
                    </div>
                  
                    <!-- update-box: [+email] -->
                    <div class="update-profile" id="email">
                      <div class="updprof-error">[[+error.message]]</div>
                      <form class="form lb_form" action="[[~[[*id]]]]" method="post">
                        <input type="hidden" name="nospam:blank" value="" />
                        <label for="fullname">[[!%login.email]] <span class="error">[[+error.email]]</span> </label>
                        <input type="text" name="email" value="[[+email]]" />
                        <input class="btn" type="submit" name="login-updprof-btn" value="[[!%login.update_profile]]" />
                      </form>
                    </div>
                  


                  So ... lets say I wanna change the email ... that works without affecting mobilephone number BUT dob goes blank. I can also change mobile phone number without affecting email. I can also set dob without affecting email or mobilephone ... so I’ve been racking my brain as to why the dob keeps getting blanked out when I update other fields.

                  I thought its coz I had ’!’ in my [[!+dob:date=`%a %b %e, %Y`]] call ... but if I put [[+dob:date=`%a %b %e, %Y`]] without the ! I get a blank ...

                  I also thought that maybe my problems were because of the prehook.

                  Any insight?

                  Been on this the whooooole day :-(
                  • Would need to see your prehook.

                    You’re missing one [ in your dob value.

                    And make sure *all* placeholders that deal with dynamic data are called uncached..

                    I suspect you will need a posthook as well (tho I’m not familiar with the profile update snippet) to reformat the date into the syntax the database is expecting... I think that’s a unix timestamp.
                      Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                      Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                      • 14372
                      • 49 Posts
                      The ’[’ is there on my end. That was a mistake in pasting the code here ...

                      This is my prehook ...

                      <?php
                      $dob = $hook->getValue('dob');
                        $hook->setValue('dob',strtotime($dob));
                        return true;
                      ?>


                      I guess a posthook would work, to format the timestamp for display just like an output modifier ... however the output modifiers were made to do just that ... format the output ... the DB stores the timestamp ... hence the prehook to format my datepicker input into a timestamp, as is in the above snippet ....

                      UPDATE:

                      Uncached mobilephone number and changed the email ... the mobile number stays and the dob went blank ... same thing when i edit mobile number ... dob goes blank .... email stays.