Suggestion: Put the product page index at top and bottom

Post feature requests to this forum and a pre-configured poll will automatically be created for you.
Post Reply

How important is this enhancement to you?

It's a critical enhancement that I must have.
0
No votes
It's an important enhancement but others are more critical.
0
No votes
I'd like to have it but it's not that important.
1
100%
I'd never use this feature.
0
No votes
 
Total votes: 1

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Suggestion: Put the product page index at top and bottom

Post by AbleMods » Wed Dec 05, 2007 7:35 am

When browsing for products in the catalog, the page number index section is only at the bottom right. It would a nice interface improvement to have those page number links both at the top and bottom of the page, same side.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
sohaib
Developer
Developer
Posts: 1079
Joined: Fri Jan 23, 2004 1:38 am

Post by sohaib » Fri Dec 07, 2007 5:23 am

Request for enhancement posted for future revisions.

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Post by compunerdy » Fri Dec 07, 2007 9:51 am

Code: Select all

 

 asp:Panel ID="PagerPanel" runat="server"
                div class="paging"
                    asp:Repeater ID="PagerControls" runat="server" OnItemCommand="PagerControls_ItemCommand"
                        <ItemTemplate>
                            a class='<Eval>'  href='<Eval>'><Eval>
                        </ItemTemplate>
                    /asp:Repeater
                </div>
            /asp:Panel        
This code generates the paging and you can move it to the top easily enough. I just dont know how to get it to allow you to show it at the top and the bottom. If you put the code in both spots it throws an error.

Hmmm..nevermind, it wont let me paste the code correctly. The code is not correct as I had to modify it in order for it to display here.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Post by jmestep » Fri Dec 07, 2007 12:42 pm

You need to click Disable HTML in this post to get it to display.
On your code, did it work if you gave the control a different ID?
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Post by compunerdy » Fri Dec 07, 2007 1:28 pm

Code: Select all

<asp:Panel ID="PagerPanel" runat="server">
                <div class="paging">
                    <asp:Repeater ID="PagerControls" runat="server" OnItemCommand="PagerControls_ItemCommand">
                        <ItemTemplate>
                            <a class='<%#Eval("TagClass")%>'  href='<%#Eval("NavigateUrl")%>'><%#Eval("Text")%></a>
                        </ItemTemplate>
                    </asp:Repeater>
                </div>
            </asp:Panel>   
Ok here is the correct code then. I tried to name it like PagerPanel2 etc.. which made it so no errors showed but it didnt show anything either.

User avatar
troutlet
Lieutenant (LT)
Lieutenant (LT)
Posts: 77
Joined: Mon Sep 24, 2007 3:01 am
Location: USA
Contact:

Post by troutlet » Fri Dec 14, 2007 5:01 am

Post feature requests to this forum. PLEASE VOTE on your favorite feature ideas by posting your vote to it's thread!
yes!

User avatar
batmike
Commander (CMDR)
Commander (CMDR)
Posts: 123
Joined: Tue Sep 04, 2007 10:46 am
Location: Minneapolis, MN
Contact:

Post by batmike » Thu Feb 07, 2008 1:22 pm

In case anyone is still interested in trying this out ... or you've figured it out by now. I went through the ascx file and made two sections and then went through the ascx.cs file and duplicated the code so there's a paging event 1 and paging event 2 but they both work together on all the pages I've tested.

The only thing I would really like to do - and if anyone could help me that would be great - would be to show all the page numbers all the time, instead of replacing the previous pages with the back arrow.

Anyway here is the ascx page code:

Part 1 ... top section:

Code: Select all

        <asp:Panel ID="PagerPanel1" runat="server">
            <div class="paging">
                <asp:Repeater ID="PagerControls1" runat="server" OnItemCommand="PagerControls_ItemCommand1">
                       <ItemTemplate>
                           <a class='<%#Eval("TagClass")%>'  href='<%#Eval("NavigateUrl")%>'><%#Eval("Text")%></a>
                       </ItemTemplate>
                </asp:Repeater>
            </div>
        </asp:Panel> 
Part 2 ... bottom section:

Code: Select all

            <asp:Panel ID="PagerPanel2" runat="server">
                <div class="paging">
                    <asp:Repeater ID="PagerControls2" runat="server" OnItemCommand="PagerControls_ItemCommand2">
                        <ItemTemplate>
                            <a class='<%#Eval("TagClass")%>'  href='<%#Eval("NavigateUrl")%>'><%#Eval("Text")%></a>
                        </ItemTemplate>
                    </asp:Repeater>
                </div>
            </asp:Panel>

And here is the ascx.cs code (Just replace the code from #region PagingControls on down to the bottom of the file, except for the ending curly brace:

Code: Select all

    #region PagingControls1

    protected void BindPagingControls1()
    {
        if (_LastPageIndex > 0)
        {
            PagerPanel1.Visible = true;
            List<PagerLinkData1> pagerLinkData1 = new List<PagerLinkData1>();
            float tempIndex1 = ((float)_HiddenPageIndex / 10) * 10;
            int currentPagerIndex1 = (int)tempIndex1 ;

            int lastPagerIndex1 = currentPagerIndex1 + _PageSize;
            if (lastPagerIndex1 > _LastPageIndex) lastPagerIndex1 = _LastPageIndex;
            string baseUrl;
            if (_Category != null) baseUrl = this.Page.ResolveClientUrl(_Category.NavigateUrl) + "?";
            else baseUrl = NavigationHelper.GetStoreUrl(this.Page, "Search.aspx?");
            if (!string.IsNullOrEmpty(_Keywords)) baseUrl += "k=" + Server.UrlEncode(_Keywords) + "&";
            if (_ManufacturerId != 0) baseUrl += "m=" + _ManufacturerId.ToString() + "&";
            baseUrl += "p=";
            string navigateUrl;
            if (currentPagerIndex1 > 0)
            {
                navigateUrl = baseUrl + (currentPagerIndex1 - 1).ToString();
                pagerLinkData1.Add(new PagerLinkData1("<", navigateUrl, (currentPagerIndex1 - 1), true));
            }
            while (currentPagerIndex1 <= lastPagerIndex1)
            {
                string linkText = ((int)(currentPagerIndex1 + 1)).ToString();
                if (currentPagerIndex1 != _HiddenPageIndex)
                {
                    navigateUrl = baseUrl + currentPagerIndex1.ToString();
                    pagerLinkData1.Add(new PagerLinkData1(linkText, navigateUrl, currentPagerIndex1, (currentPagerIndex1 != _HiddenPageIndex)));
                }
                else
                {
                    navigateUrl = "#";
                    pagerLinkData1.Add(new PagerLinkData1(linkText, navigateUrl, currentPagerIndex1, (currentPagerIndex1 != _HiddenPageIndex), "current"));
                }
                currentPagerIndex1++;
            }
            if (lastPagerIndex1 < _LastPageIndex)
            {
                navigateUrl = baseUrl + (lastPagerIndex1 + 1).ToString();
                pagerLinkData1.Add(new PagerLinkData1(">", navigateUrl,lastPagerIndex1+1, true));
            }
            PagerControls1.DataSource = pagerLinkData1;
            PagerControls1.DataBind();
        }
        else
        {
            PagerPanel1.Visible = false;
        }
    }

    public class PagerLinkData1
    {
        private string _Text;
        private int _PageIndex;
        private string _NavigateUrl;
        public int PageIndex { get { return _PageIndex; } }
        private bool _Enabled;
        public string Text { get { return _Text; } }
        public string NavigateUrl { get { return _NavigateUrl; } }
        public bool Enabled { get { return _Enabled; } }
        private string _tagClass;
        public string TagClass { get { return _tagClass; } set { _tagClass = value; } } 
        public PagerLinkData1(string text, string navigateUrl,int pageIndex, bool enabled)
        {
            _Text = text;
            _NavigateUrl = navigateUrl;
            _PageIndex = pageIndex;
            _Enabled = enabled;
        }

        public PagerLinkData1(string text, string navigateUrl, int pageIndex, bool enabled,string tagClass)
        {
            _Text = text;
            _NavigateUrl = navigateUrl;
            _PageIndex = pageIndex;
            _Enabled = enabled;
            _tagClass = tagClass;
        }
    }

    protected void PagerControls_ItemCommand1(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Page")
        {
            InitializePagingVars(false);
            _HiddenPageIndex = AlwaysConvert.ToInt((string)e.CommandArgument);
            if (_HiddenPageIndex < 0) _HiddenPageIndex = 0;
            if (_HiddenPageIndex > _LastPageIndex) _HiddenPageIndex = _LastPageIndex;
            HiddenPageIndex.Value = _HiddenPageIndex.ToString();
        }
    }
    protected void SetPagerIndex1()
    {
        InitializePagingVars(false);
        _HiddenPageIndex = AlwaysConvert.ToInt(Request.QueryString["p"]);
        if (_HiddenPageIndex < 0) _HiddenPageIndex = 0;
        if (_HiddenPageIndex > _LastPageIndex) _HiddenPageIndex = _LastPageIndex;
        HiddenPageIndex.Value = _HiddenPageIndex.ToString();
    }
    #endregion

    #region PagingControls

    protected void BindPagingControls2()
    {
        if (_LastPageIndex > 0)
        {
            PagerPanel2.Visible = true;
            List<PagerLinkData2> pagerLinkData2 = new List<PagerLinkData2>();
            float tempIndex2 = ((float)_HiddenPageIndex / 10) * 10;
            int currentPagerIndex2 = (int)tempIndex2 ;

            int lastPagerIndex2 = currentPagerIndex2 + _PageSize;
            if (lastPagerIndex2 > _LastPageIndex) lastPagerIndex2 = _LastPageIndex;
            string baseUrl;
            if (_Category != null) baseUrl = this.Page.ResolveClientUrl(_Category.NavigateUrl) + "?";
            else baseUrl = NavigationHelper.GetStoreUrl(this.Page, "Search.aspx?");
            if (!string.IsNullOrEmpty(_Keywords)) baseUrl += "k=" + Server.UrlEncode(_Keywords) + "&";
            if (_ManufacturerId != 0) baseUrl += "m=" + _ManufacturerId.ToString() + "&";
            baseUrl += "p=";
            string navigateUrl;
            if (currentPagerIndex2 > 0)
            {
                navigateUrl = baseUrl + (currentPagerIndex2 - 1).ToString();
                pagerLinkData2.Add(new PagerLinkData2("<", navigateUrl, (currentPagerIndex2 - 1), true));
            }
            while (currentPagerIndex2 <= lastPagerIndex2)
            {
                string linkText = ((int)(currentPagerIndex2 + 1)).ToString();
                if (currentPagerIndex2 != _HiddenPageIndex)
                {
                    navigateUrl = baseUrl + currentPagerIndex2.ToString();
                    pagerLinkData2.Add(new PagerLinkData2(linkText, navigateUrl, currentPagerIndex2, (currentPagerIndex2 != _HiddenPageIndex)));
                }
                else
                {
                    navigateUrl = "#";
                    pagerLinkData2.Add(new PagerLinkData2(linkText, navigateUrl, currentPagerIndex2, (currentPagerIndex2 != _HiddenPageIndex), "current"));
                }
                currentPagerIndex2++;
            }
            if (lastPagerIndex2 < _LastPageIndex)
            {
                navigateUrl = baseUrl + (lastPagerIndex2 + 1).ToString();
                pagerLinkData2.Add(new PagerLinkData2(">", navigateUrl,lastPagerIndex2+1, true));
            }
            PagerControls2.DataSource = pagerLinkData2;
            PagerControls2.DataBind();
        }
        else
        {
            PagerPanel2.Visible = false;
        }
    }

    public class PagerLinkData2
    {
        private string _Text;
        private int _PageIndex;
        private string _NavigateUrl;
        public int PageIndex { get { return _PageIndex; } }
        private bool _Enabled;
        public string Text { get { return _Text; } }
        public string NavigateUrl { get { return _NavigateUrl; } }
        public bool Enabled { get { return _Enabled; } }
        private string _tagClass;
        public string TagClass { get { return _tagClass; } set { _tagClass = value; } } 
        public PagerLinkData2(string text, string navigateUrl,int pageIndex, bool enabled)
        {
            _Text = text;
            _NavigateUrl = navigateUrl;
            _PageIndex = pageIndex;
            _Enabled = enabled;
        }

        public PagerLinkData2(string text, string navigateUrl, int pageIndex, bool enabled,string tagClass)
        {
            _Text = text;
            _NavigateUrl = navigateUrl;
            _PageIndex = pageIndex;
            _Enabled = enabled;
            _tagClass = tagClass;
        }
    }

    protected void PagerControls_ItemCommand2(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Page")
        {
            InitializePagingVars(false);
            _HiddenPageIndex = AlwaysConvert.ToInt((string)e.CommandArgument);
            if (_HiddenPageIndex < 0) _HiddenPageIndex = 0;
            if (_HiddenPageIndex > _LastPageIndex) _HiddenPageIndex = _LastPageIndex;
            HiddenPageIndex.Value = _HiddenPageIndex.ToString();
        }
    }
    protected void SetPagerIndex2()
    {
        InitializePagingVars(false);
        _HiddenPageIndex = AlwaysConvert.ToInt(Request.QueryString["p"]);
        if (_HiddenPageIndex < 0) _HiddenPageIndex = 0;
        if (_HiddenPageIndex > _LastPageIndex) _HiddenPageIndex = _LastPageIndex;
        HiddenPageIndex.Value = _HiddenPageIndex.ToString();
    }
    #endregion

    protected void Page_PreRender(object sender, EventArgs e)
    {
        //BIND PAGE
        BindPage();
    }

User avatar
m_plugables
Commander (CMDR)
Commander (CMDR)
Posts: 149
Joined: Tue Mar 11, 2008 12:44 am
Contact:

Post by m_plugables » Mon Mar 24, 2008 4:41 am

You can use the PageButtonCount property of the GridView to set how many indexed page numbers you want to show

Post Reply