Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

link to next/prev in the headers vs page body

Guest
Nov 02, 2009 Nov 02, 2009

The question arose when I was looking at the Dreamweaver help section on page headers and I noticed that the headers could contain next/previous information.  I asked the question there about the utility of putting that info in the headers rather than in the page body itself. I was directed here.

This is my question:

In a series of pages, I'm assuming that I can use php to supply links for Next, Prev, Index in the headers because I am already using it for the page titles.  Is there any downside to this (other than, of course, insuring that the links exist, etc.)?  Would I then have an href 'Next' in the page display which would refer to the header?  Would it be better to put the php at the href in page itself and not put it into the header?  I guess the bottom line to my question is this: php can figure out which page should be made next.

Where is the best place to put this if the user wants to go to the next page. I have a series of monthly calendars, starting with Sept 2006 and complete to Dec 2009 (with more to be added as time marches on). Except for Nov & Dec 2009, these pages are html and will be converted to php. 

Please understand, I know how to put the links into the page body and my calendar names are based on the date. My question centers on whether there is and advantage in putting the Next/Previous info in the header and if so, what is the advantage?

As far as the actual page name, it goes like this: calendarYYYY_MM.php where YYYY = 4 digit year and MM = 2 digit month.

The base page, calendar.php takes the viewer to the current month, whatever that is.  I know how to put the links in for the page body. Do I use the page header in calendar.php to generate the page name for the other pages?  Is that how it works?

Any guidance on this would be helpful. Thanks.

TOPICS
Server side applications
602
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 02, 2009 Nov 02, 2009

moving this thread from the ADDT "PHP Application Development" forum to the Dreamweaver "Application Development" forum.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 09, 2009 Nov 09, 2009

My question has been moved to the 'more appropriate place" but no one has answered it. Is there an answer?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 09, 2009 Nov 09, 2009

Personally speaking, I like sites that display recordset navigation both before AND after the records are displayed, especially if the pages are long and require scrolling.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 10, 2009 Nov 10, 2009
LATEST

iskeen wrote:

As far as the actual page name, it goes like this: calendarYYYY_MM.php where YYYY = 4 digit year and MM = 2 digit month.

The base page, calendar.php takes the viewer to the current month, whatever that is.

Since you have a predictable pattern for the page name, it's very simple. The following custom functions will do the job (I have added comments to the first one to explain how it works):

function nextMonth() {
  // Get the filename minus extension
  $current = basename($_SERVER['SCRIPT_FILENAME'], '.php');


  // Remove 'calendar' and split on underscore
  $dateparts = explode('_', substr($current, 8));
  $year = $dateparts[0];
  $month = $dateparts[1];


  // Adjust the date
  if ($dateparts[1] == 12) {
       $year = $year+1;
       $month = 1;
  } else {
       $month = $month+1;
  }


  // Add leading 0 to month if only one character
  if (strlen($month) < 2) {
       $month = "0$month";
  }


  // Build the page name
  return "calendar{$year}_{$month}.php";
}


function prevMonth() {
  $current = basename($_SERVER['SCRIPT_FILENAME'], '.php');
  $dateparts = explode('_', substr($current, 8));
  $year = $dateparts[0];
  $month = $dateparts[1];
  if ($dateparts[1] == 1) {
       $year = $year-1;
       $month = 12;
  } else {
       $month = $month-1;
  }
  if (strlen($month) < 2) {
       $month = "0$month";
  }
  return "calendar{$year}_{$month}.php";
}

All you need to do is create the links like this:

<a href="<?php echo prevMonth(); ?>">Previous month</a>

<a href="<?php echo nextMonth(); ?>">Next month</a>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines