Zen Cart Logo
Forums / Customization from the Admin / Displaying the correct page after inserting a "Music Genre" extra

Displaying the correct page after inserting a "Music Genre" extra

Views: 758

Results 1 to 4 of 4
6 Dec 2011, 9:05 AM
#1
kamion avatar

kamion

New Zenner

Join Date:
Mar 2011
Posts:
93
Plugin Contributions:
0

Displaying the correct page after inserting a "Music Genre" extra

At the moment, the Admin->Extras->Music Genre displays up to 20 rows per page.

Currently, whenever I insert a Music Genre (when there are more than 20 entries), and click "Save", it will then go to show Page 1.

How can I modify this behaviour so that it displays the page where the new entry has been inserted?

For example, let's say I already have 50 entries in Music Genre so it will be split into 3 pages. I then insert a new Music Genre that alphabetically slots in at listing number 38 but has the mID of 51.

Current behaviour after I add the new Music Genre is to display Page 1. How can I change it to display page 2 so that mID 51 can be highlighted at listing number 38 automatically after clicking on "Save"?

6 Dec 2011, 7:07 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Displaying the correct page after inserting a "Music Genre" extra

You could try this by adding the code in RED:

  $music_genre_query_raw = "select * from " . TABLE_MUSIC_GENRE . " order by music_genre_name";

// Split Page
// reset page when page is unknown
if (($_GET['page'] == '' or $_GET['page'] == '1') and $_GET['mID'] != '') {
  $check_page = $db->Execute($music_genre_query_raw);
  $check_count=1;
  if ($check_page->RecordCount() > MAX_DISPLAY_SEARCH_RESULTS) {
    while (!$check_page->EOF) {
      if ($check_page->fields['music_genre_id'] == $_GET['mID']) {
        break;
      }
      $check_count++;
      $check_page->MoveNext();
    }
    $_GET['page'] = round((($check_count/MAX_DISPLAY_SEARCH_RESULTS)+(fmod_round($check_count,MAX_DISPLAY_SEARCH_RESULTS) !=0 ? .5 : 0)),0);
  } else {
    $_GET['page'] = 1;
  }
}

  $music_genre_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $music_genre_query_raw, $music_genre_query_numrows);

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

7 Dec 2011, 1:50 AM
#3
kamion avatar

kamion

New Zenner

Join Date:
Mar 2011
Posts:
93
Plugin Contributions:
0

Re: Displaying the correct page after inserting a "Music Genre" extra

Works like a charm! Thanks, Ajeh!

7 Dec 2011, 1:52 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Displaying the correct page after inserting a "Music Genre" extra

You are most welcome ... thanks for the update that this worked for you ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!