#1
I need to show less number of topics per page on a mobile device. Can I do this and if yes, then how would I do it?
I want to show only 7 topics per page on a mobile device. The screen shot of this topics page is as in link below.

https://goo.gl/jmktUD 
Topic Starter
  • vcsharp
  • Rank: YAF Commander
  • Reputation:
    Honored
    85.4%
  • Joined: 03/10/2017
  • Posts: 76
  •  Man  India
  • Thanks: 24 times
  • Was thanked: 1 time(s) in 1 post(s)
#2
I found a setting for Topics Per Page under Admin > Host Administration > Host Settings > Display tab. It has a default value of 15. So, topics grid page size can be changed through this setting, but there is no special setting for Topics Per Page on Mobile
If one needs to change it for mobile device then the only option I found was change code in controls/topics.ascx.cs. All places in BindData method that sets page size needs to be changed and there are two places in this method where page size is being set as shown in original code below.

Original code in controls/topics.ascx.cs
        private void BindData()
        {
           //code here has been omitted
           . . . //omited code
            this.Pager.PageSize = this.Get<YafBoardSettings>().TopicsPerPage;
           .  .  .//omitted code
            int baseSize = this.Get<YafBoardSettings>().TopicsPerPage;



The two lines in above code that set page size need to be changed to code like below.

Modified code in controls/topics.ascx.cs
            //SD. changed topics grid page size if it's a mobile device
            if (Request.Browser.IsMobileDevice)
            {
                this.Pager.PageSize = 7;//set this to a appropriate value according to your needs
            }
            else
            {
                this.Pager.PageSize = this.Get<YafBoardSettings>().TopicsPerPage;
            }
            .  .  . //omitted code
           int baseSize = this.Get<YafBoardSettings>().TopicsPerPage;
            //SD. changed topics grid page size if it's a mobile device
            if (Request.Browser.IsMobileDevice)
            {
                baseSize = 7;
            }


After above code change make sure to copy over YAF.dll to the bin directory of your website.
Topic Starter
  • vcsharp
  • Rank: YAF Commander
  • Reputation:
    Honored
    85.4%
  • Joined: 03/10/2017
  • Posts: 76
  •  Man  India
  • Thanks: 24 times
  • Was thanked: 1 time(s) in 1 post(s)
Forum Jump  
  • You cannot post new topics in this forum.
  • You cannot reply to topics in this forum.
  • You cannot delete your posts in this forum.
  • You cannot edit your posts in this forum.
  • You cannot create polls in this forum.
  • You cannot vote in polls in this forum.

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved