Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

How to change the order surveys shown on homepage

  • batpurev
  • batpurev's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 weeks ago #214646 by batpurev
Hi all,

Does anyone know how to change the order surveys shown on the homepage? Did some search but could not find similar question.

thanks,
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 weeks ago #214649 by Joffm
What do you mean by "homepage"

The "survey list" page?
 
Here you click the headers.

Or the page of public surveys?
 

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • batpurev
  • batpurev's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 weeks ago #214650 by batpurev
Yes surveys listed publicly. I want to re-order, right now it seems like it is listing by its creation date.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 weeks ago #214653 by tpartner
I assume that you want to sort them alphabetically.

There may be a way to sort the array via Twig but I have a JavaScript solution...

1) Extend your default survey theme.

2) Make sure that this new theme is assigned as the "Default theme in the global settings.

3) Add this to the end of layout_survey_list.twig:

Code:
<script type="text/javascript" charset="utf-8">  
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Create an array of survey titles
    var surveyTitles = [];
    $('.surveys-list a.surveytitle').each(function(i) {
      $(this).attr('data-sid', $(this).attr('href').split('index.php/')[1].split('?')[0]);
      surveyTitles.push($.trim($(this).text()));        
    });
 
    // Sort the titles
    surveyTitles.sort();
 
    // Insert the survey links in sorted order
    $(surveyTitles).each(function(i, val) {
      var thisLink = $('a.surveytitle').filter(function(e) {
        return $.trim($(this).text()) == val;
      });  
      $('.surveys-list').append(thisLink.closest('li'));      
    });
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • batpurev
  • batpurev's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 weeks ago #214738 by batpurev
this did exactly what I needed. thank you so much
The topic has been locked.
  • batpurev
  • batpurev's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 6 hours ago #215374 by batpurev
hi,

I extended the default theme but how to add custom footer with links in it?

Thanks
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 6 hours ago #215378 by tpartner
This is unrelated to this topic. Please start a new topic.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 6 hours ago #215379 by Joffm
Use the "footer.twig" to insert your desired content.
 
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose