8 Replies Latest reply on Aug 19, 2013 1:13 AM by Liam Dilley

    I need to control resultsPerPage without hardcoding the value

    ChrisAtMarcus

      I need to be able to setup the resultsPerPage parameter in the webapps module line as a variable rather than a constant.

       

      e.g.

       

      {module_webapps,ID   ,filter,itemID,notUsed,targetFrame,useBackup,resultsPerPage,hideEmptyMessage,rowLength,So rt}

       

      I have two webapps displayed on a page - one showing news, one showing events.  At times I need 2 news items and 4 events while at other times I might need 1 news item and 5 events.

       

      I thought that if there was a way I could store the numbers (e.g. in files that could be included, in content holders, in web apps etc) then it would be easier to change than getting into the template and making the change there - which is fraught with danger should the wrong bit be changed.

       

      But I can't see a way of doing it.  Obviously javascript is no use since it needs to happen server side before the {module... invocation occurs.

       

      Is there a way?  Or am I going to have to setup five separate templates and use this method to select the numbers.  I don't really want to do this because it means five templates to keep syncronized in the event of changes but changing a '2' to '3' in the middle of a very user unfriendly template is far less attractive...

        • 1. Re: I need to control resultsPerPage without hardcoding the value
          Liam Dilley Adobe Community Professional & MVP

          A module will not render inside that one and you can not do it with Javascript because it is after that content has rendered as you noted.

          Currently no way to make that per page value dynamic.

           

          Big question is what you trying to achieve? If you let us folk know this we may offer an alternative method or sollution.

          • 2. Re: I need to control resultsPerPage without hardcoding the value
            ChrisAtMarcus Level 1

            Darn.  But I suspected as much.

             

            We have a home page which displays a bunch of stuff - including an area shared between two web apps (News and Events).  Because it is a limited amount of real estate, we can essentially fit 6 'items' in the space - i.e. a combination of X news items and Y event items where X+Y equals 6.  So I am having to go into the template and change the two lines for these two web apps to reflect the correct values.  Finding the appropriate area in the template is a bit of a pain and making sure I change the exact piece of the line (i.e. don't accidentally delete/insert commas etc) is also a pain.  It's worse if someone else is called to make the change because at least I am familiar with it.   SO I hoped to find a more parameter driven solution... 

             

            Ideally, the web apps could have a DEFAULT RESULTS value and the parameter 'resultsPerPage' could be set to -1 to use that default.  Then at least it would mean just updating that field in Business Catalyst...

             

            The only other solution is for me to have the five different versions of the template which is probably going to be safer all things considered...

             

            Thanks for you help though

            • 3. Re: I need to control resultsPerPage without hardcoding the value
              Liam Dilley Adobe Community Professional & MVP

              You should look to ajax in your content with some option controls and do it that way?

               

              You could look to explore using content holders and the named option as well if it will be any easier...

               

              {module_contentholder,name=""} Where name is the web app/file name (no extension)

              1 person found this helpful
              • 4. Re: I need to control resultsPerPage without hardcoding the value
                ChrisAtMarcus Level 1

                Not sure about ajax - no experience there at all.

                 

                BUT I didn't know about the 'name=' option - that will probably work fine.

                 

                I can use a content module in the template (e.g. NEWS_AND_EVENTS)

                Then have that invoke one of 5 other modules (e.g. N1E5, N2E4, N3E3 etc...)  which makes it all much more supportable and easy to handle with simple documentation.  It also means only one template ...

                 

                That's a great suggestion - many many thanks.

                • 5. Re: I need to control resultsPerPage without hardcoding the value
                  TheBCMan Adobe Community Professional

                  You can do it, but it is a little bit of a pain in the butt, you AJAX pull in an HTML page that has the BC tag in it with the hard coded value.

                   

                  So for example, if you want to give the person the option of 5,10, 20 items per page, you need to make three files that have the hard coded values in them.

                   

                  results_5.html:

                  {module_webapps,ID ,filter,itemID,notUsed,targetFrame,useBackup,5,hideEmpty Message,rowLength,Sort}

                   

                  results_10.html:

                  {module_webapps,ID ,filter,itemID,notUsed,targetFrame,useBackup,10,hideEmpty Message,rowLength,Sort}

                   

                  etc...

                   

                  Then use Javascript / JQuery to AJAX request the file you need and display the content as HTML dynamically into a DIV. Semi-dynamic, hopefully you don't need too many results per page options.

                  • 7. Re: I need to control resultsPerPage without hardcoding the value
                    ChrisAtMarcus Level 1

                    The actual technicalities of the Ajax weren't covered but I'm more inclined to go with the nested content holders because it is simpler for myself and others who may support this.  In fact, I didn't know until you posted Liam that it was possible to use the name= option.  This has revolutionized some of the spaghetti that existed in the site I support (not mine!) because of course there is nothing meaningful in {module_contentholder,74833}.  I understand that using the name might have a problem if the name is changed but that's wearable as we don't change that sort of thing anyway.

                     

                    SO thanks to you, a problem has not only been solved but I have learnt how to make the site even more supportable.  Many thanks.