back link from details pages
            3 posts by 2 authors in: Forums > CMS Builder
Last Post: January 24, 2012   (RSS)          
By rez - January 24, 2012 - edited: January 25, 2012
          LIST PAGE
DETAILS
So I have a portfolio page that shows the list on the same page if a category is selected (from my sidebar):
http://www.mysite.com/portfolio.php?Logos-13
 
There are also latest projects on the home page that go directly to the details page:
<a href="<?php echo $featuredRecord['_link'] ?>">read more…</a></div>
When viewing the details page:
http://www.mysite.com/projectdetails.php?Logo-9
The back to list link from the details goes to my /portfolio.php as set in CMBS viewing urls. This link from details takes me to that page without a record selected, so there is just some intro text to select a category in my sidebar due to
<?php if (!$selectedCategory): ?>
1. if i came from page 4 of a paginated list of projects, i would want to return to that list on page 4 and not the beginning or portfolio.php page.
2. If i came from the homepage to the details, i would want the link from the details to hopefully also go to page 4 as well if thats the page its listed on, even though i didnt come from that page. at the very least, i would want in this case to go to page 1 of the full list.
I've looked at referrer code here from chris with something about mypage.php?page= but I dont see "page" referred to in my links and just couldn't get anything working all day yesterday.
thanks for help with this.
                                        
          list($categoryRecords, $selectedCategory) = getCategories(array( 
    'tableName'           => 'project_cats', 
    //'selectedCategoryNum' => '',         // defaults to getNumberFromEndOfUrl() 
    'categoryFormat'      => 'showall',  // showall, onelevel, twolevel 	
  )); 
// if there is a category selected, make the multi selections  
  list($itemsRecords, $itemsMetaData) = getRecords(array( 
    'tableName' => 'projects', 
    'perPage'     => '4',	
    //'debugSql' =>'true'	
  ));    
?>
<?php if ($selectedCategory): ?>                             
	  <?php foreach ($itemsRecords as $itemRecord): ?> 
       
      <!--Output items in this category  --> 
        <ul class="portfolio-list">    
	      <li><strong>Client: </strong><?php echo $itemRecord['client:label'];?> | <strong>Project: </strong><?php echo $itemRecord['title'];?><br />
       <?php foreach ($itemRecord['image'] as $upload): ?>
          <?php if ($upload['hasThumbnail']): ?>
<a href="<?php echo $upload['thumbUrlPath'] ?>" rel="prettyPhoto[project]"><img src="<?php echo $upload['thumbUrlPath2'] ?>" width="<?php echo $upload['thumbWidth2'] ?>" height="<?php echo $upload['thumbHeight2'] ?>" alt="" /></a><br/>
          <?php endif ?>
        <?php endforeach ?>
      <!-- STEP2a: /Display Uploads --> 
<a href="<?php echo $itemRecord['_link'] ?>">view details</a><br/>                   
		  </li>
	</ul> 
      <!--/Ouptut items in this category -->	     
	  <?php endforeach ?> 
 
<!-- /Output Categories --> 
     <?php if (!$itemsRecords): ?>
      We are updating this section. Please contact us for more information.<br/><br/>
    <?php endif ?>  
	    <?php endif ?>DETAILS
  list($projectsRecords, $projectsMetaData) = getRecords(array(
    'tableName'   => 'projects',
    'where'       => whereRecordNumberInUrl(1),
    'limit'       => '1',
  ));
  $projectsRecord = @$projectsRecords[0]; // get first record
  // show error message if no matching record is found
  if (!$projectsRecord) { dieWith404("Record not found!"); }
        <?php foreach ($projectsRecord['image'] as $upload): ?>
          <?php if ($upload['hasThumbnail']): ?>
            <img src="<?php echo $upload['thumbUrlPath2'] ?>" width="<?php echo $upload['thumbWidth2'] ?>" height="<?php echo $upload['thumbHeight2'] ?>" alt="" /><br/>
          <?php endif ?>
        <?php endforeach ?><br /><br />
<h2 class="title"><?php echo $projectsRecord['title'] ?></h2>
      Date: <?php echo date("D, M jS, Y", strtotime($projectsRecord['date'])) ?><br/>
<?php echo $projectsRecord['content'] ?><br/>        
    <?php if (!$projectsRecord): ?>
      Site maintenance. Pleas contact us for more information.
    <?php endif ?>
  <!-- /STEP2: Display Records -->
<a href="<?php echo $projectsMetaData['_listPage']; ?>"><< Back to list page</a> - 
  <a href="mailto:?subject=<?php echo urlencode(thisPageUrl()) ?>">Email this Page</a>So I have a portfolio page that shows the list on the same page if a category is selected (from my sidebar):
http://www.mysite.com/portfolio.php?Logos-13
There are also latest projects on the home page that go directly to the details page:
<a href="<?php echo $featuredRecord['_link'] ?>">read more…</a></div>
When viewing the details page:
http://www.mysite.com/projectdetails.php?Logo-9
The back to list link from the details goes to my /portfolio.php as set in CMBS viewing urls. This link from details takes me to that page without a record selected, so there is just some intro text to select a category in my sidebar due to
<?php if (!$selectedCategory): ?>
1. if i came from page 4 of a paginated list of projects, i would want to return to that list on page 4 and not the beginning or portfolio.php page.
2. If i came from the homepage to the details, i would want the link from the details to hopefully also go to page 4 as well if thats the page its listed on, even though i didnt come from that page. at the very least, i would want in this case to go to page 1 of the full list.
I've looked at referrer code here from chris with something about mypage.php?page= but I dont see "page" referred to in my links and just couldn't get anything working all day yesterday.
thanks for help with this.
Re: [rez] back link from details pages
By rez - January 24, 2012 - edited: January 24, 2012
          oh... I just realized that these projects may be in multiple categories so in the second example coming from the homepage, I actually dont know what I want to link back to. I'm thinking the link should say view "full portfolio or select a category on the right" in that case and use the default /portfolio.php for the link.
The first example would still go back to the list page that was being viewed, page 4 in that example. Any solution here?
Some projects will be shared on facebook with a link or may be found in google so just going one page back isn't my favorite option. How do you suggest i do this? the history -1 code i have seen in the past?
                                        
        The first example would still go back to the list page that was being viewed, page 4 in that example. Any solution here?
Some projects will be shared on facebook with a link or may be found in google so just going one page back isn't my favorite option. How do you suggest i do this? the history -1 code i have seen in the past?
Re: [rez] back link from details pages
By (Deleted User) - January 24, 2012
          Hi Rez,
You can use $projectsRecord ['category'] to provide the category number to go back to for a 'back' link, for example:
This will take you to the listPage with the category for that record selected.
Otherwise, to go back to the previous page you could just use a cookie to store the lastUrl then use the value of that cookie to create the link.
Hope that helps,
Tom
                                        
        You can use $projectsRecord ['category'] to provide the category number to go back to for a 'back' link, for example:
<a href='listPage.php?<?php echo $projectRecord['category']; ?>'>Back To Category For This Item</a>This will take you to the listPage with the category for that record selected.
Otherwise, to go back to the previous page you could just use a cookie to store the lastUrl then use the value of that cookie to create the link.
Hope that helps,
Tom