7 Replies Latest reply on Oct 21, 2016 11:22 PM by Liam Dilley

    List the latest webapps item 'only'

    DonScotus Level 1

      Please can someone explain how to list the latest webapps item only. In the legacy tag system this used to work well - { module_webapps,4567, l, 1 }. How can this be done using the New Named Parameters and liquid?

       

      Thanks

        • 1. Re: List the latest webapps item 'only'
          Webmosphere.co.uk Level 3

          Use render="item" for behaviour close to the legacy >> so you have something like:

           

          {module_webapps render="item" id="4567" filter="latest" resultsPerPage="10" hideEmptyMessage="false" sortType="date" template=""}

           

          The above should list 10 latest items, sorted newest first.

           

          You might want to read more here:

          The "render" parameter

          module_webapps | Business Catalyst Developers

          • 2. Re: List the latest webapps item 'only'
            Liam Dilley Adobe Community Professional & MVP

            I unmarked that as correct as it is important to understand the module behaviour and performance.

            If you want the direct replacement to your module you would actually use:

             

            {module_webapps id="4567" filter="latest" resultsPerPage="1"}

             

            So that is the latest single item as per your module. But since it has default behaviour and possible pagination output and other elements in this use cases, with the new modules and liquid you do have a few options but lets look at the above post and explain the other elements first..

             

            render="item"

            Default behaviour, so if you are doing default you do not need to do this if it is default in the first place. While in Romania talking to the engineers about this, but since it had its opposite, they decided to include this even though this really is never needed.

             

            template=""

            This actually there to supress all template, including the default ones from being rendered so it in the above use case is an odd one. You really only do this if you also want to use collection="" which means you want to render the response inline.

             

            render="collection"

            Not mentioned but often misused and to not indicates you want to render items as a collection NOT as a single item behavior as it does normally. You really ONLY use this if you are using the default layouts. If you are using your webapp small or webapp small backup layouts 1 item layout is the normal behaviour. As a collection you would do the liquid for loop and so on instead.

            YOU DO NOT need this if you are just doing collection="myThing".

             

            So, you have a few options, and you can add as many of the named parameters as you need but you do not need them all. Suppressing templates, trying to then force them, using collection so the module pushes data to templates your not even using and so on just uses server memory. Lots of people are spamming module_data everywhere as well where the Liquid output by default already has that information. I mention everything as if your delving in its good to do it right and learn the right way rather then anything a bit sloppy.

             

            So your options are:

             

            {module_webapps id="4567" filter="latest" resultsPerPage="1"}

             

            {module_webapps id="4567" filter="latest" resultsPerPage="1" template="" collection="LatestItems"}

            This will render a collection to use below the module. Since your use case is only one item, you do not need to do a for loop either as that would be again a waste of processing and memory.

            {% assign latestItem = LatestItems.items[0] -%}

            The above line actually gives you a clean object to work with so {{latestItem.name}} etc.

             

            {module_webapps id="4567" filter="latest" resultsPerPage="1" template="PATH HERE OF FILE"}

            If you want a custom template for this rather then default

             

            {module_webapps id="4567" filter="latest" resultsPerPage="1"  render="collection"}

            Send to default small layout but use collection, The above about collections could be done in that template to be cleaner then inline.

             

            {module_webapps id="4567" filter="latest" resultsPerPage="1"  render="collection" template="PATH HERE"}

            Custom template and as collection

             

            As you can see there are several ways to do things, you do not need hide empty message for example if you are rendering as a collection and so on. But try and do as less as possible, it will be cleaner, better performing and will actually be less confusing.

            • 3. Re: List the latest webapps item 'only'
              DonScotus Level 1

              Many thanks for the insight. Well done!

              • 4. Re: List the latest webapps item 'only'
                Webmosphere.co.uk Level 3

                There was nothing wrong with that answer Liam, as the links shared would have expanded on the provided info.
                Feel free to expand on answers, but unmarking correct answers just seems like your poor attitude running amok.

                • 5. Re: List the latest webapps item 'only'
                  Liam Dilley Adobe Community Professional & MVP

                  Hi Dave,

                  It actually does not work and any case where that may work should be considered a bug.

                  {module_webapps render="item" id="13107" filter="latest" resultsPerPage="10" hideEmptyMessage="false" sortType="date" template=""}

                   

                  - Render="item" As shown and as in the docs is normal behaviour.

                  - The poster is outputting only the 1 latest item not 10

                  - Template="" means to not use the default templates but no custom template or collection has been specified.

                   

                  Placing your exact module code with a web app ID that we have lots of items on:

                  Webapp test

                   

                  Nothing is outputting. This is because no template exists - There is no place to send the data to and render an output. Coupled with what I mentioned about correct use of named parameters dave and answers on several approaches to do it correctly. I was right to do so.

                  Sorry if doing that has upset you, but it was not the correct answer.

                  • 6. Re: List the latest webapps item 'only'
                    Webmosphere.co.uk Level 3

                    You have gone to great lengths to maintain marking your answer as correct. Definitely 'A' for effort mate!

                     

                    Like I said, there's nothing wrong with the answer, as I clearly mentioned '...something like' the tag I provided, and then added links to docs which would have indicated that template="" suppresses the output and therefore needs a template to be defined.

                     

                    In regards to render="item", of course this is the normal behaviour, so remind me again, why it is wrong?

                    Lastly, resultsPerPage="10" >> don't be petty; you are not exactly know for providing spot on answers. To quote you directly:

                    Yep, I do not give just instant code snippets, this is doing the work for people.. I am not going to do your job for you. I provide the needed information that guides people to learn and implement the solution.

                    Wishlist: Batch handling with Media Downloads

                     

                    Note: my response is not because I want my answer marked correct. It is simply to ensure you don't go all 'happy hour' with the nuke codes.

                    • 7. Re: List the latest webapps item 'only'
                      Liam Dilley Adobe Community Professional & MVP

                      Hi Dave

                      What you gave does not work - I proved that. How can something that does not work be a correct answer?

                      render="item" nearly did not exist, it actually did not in the first implementation, it was done for completeness. As I have shown though it is not needed and I explained, IN DETAIL why.

                      I struggle to think you do not understand the above posts and actual example showing your code did not work, I think it is clear your comments are not about the answer here, its about how you have not liked being corrected. I think that is unprofessional.

                       

                      There is no evidence or signs anywhere that I am unmarking peoples posts as correct across the board. Contacting the OP - He did not mark your answer correct, did you do it yourself? Is this why your attacking me?