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
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:&nbsp;</strong><?php echo $itemRecord['client:label'];?>&nbsp;|&nbsp;<strong>Project:&nbsp;</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']; ?>">&lt;&lt; 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&#8230;</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 (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:

<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