How to make a back link to list page the same which came?

16 posts by 7 authors in: Forums > CMS Builder
Last Post: December 10, 2011   (RSS)

Hi
How to make a back link on article page to list page the same which came? I have few list page, on each list page have links to 2 articles, articles have a back link POWRÓT < [= Back]. I would make a link on article page which will enable me to return to the page from which I came not to the first.

On this site works: http://goo.gl/TXIr

Thanks for any solution.

Re: [esteban] How to make a back link to list page the same which came?

By Chris - February 15, 2010 - edited: February 16, 2010

Hi esteban,

So the problem is that users might be on page 3 of your list page (which uses pagination,) click a link to a detail page, and you want to provide a link back to page 3 of your list page instead of page 1?

This is a little tricky, but I have a solution for you.

On your list page, change the "_link" code from this:

<a href="<?php echo $record['_link'] ?>">

...to this:

<a href="wydarzenia-art.php?page=<?php echo @$_REQUEST['page'] ? htmlspecialchars($_REQUEST['page']) : 1 ?>&num=<?php echo $record['num'] ?>">

...replacing the code in red with the name of your record variable.

And then change the link in your detail page from:

<a href="wydarzenia-lista.php">

...to this:

<a href="wydarzenia-lista.php?page=<?php echo htmlspecialchars(@$_REQUEST['page']) ?>">

I hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [chris] How to make a back link to list page the same which came?

Almost working :-) Look at link: http://goo.gl/2hct
there displays a &num=3"> i don't know how improve code and the link is wrong not to the right article.

You wrote: "...replacing the code in red with the name of your record variable. " I do not know how to do it. What is this record variable in my case?

Thanks Chris

Re: [esteban] How to make a back link to list page the same which came?

By Chris - February 16, 2010

Hi esteban,

Sorry, my fault. I had an extra "> in the code. I've edited my post above to remove it. Please remove the code in red below from your wydarzenia-lista.php page:

<a href="wydarzenia-art.php?page=<?php echo @$_REQUEST['page'] ? htmlspecialchars($_REQUEST['page']) : 1 ?>">&num=<?php echo $record['num'] ?>">

What is this record variable in my case?


It must be already correct since the code is working.

Please let me know if you have any questions.
All the best,
Chris

Re: [esteban] How to make a back link to list page the same which came?

By pod9 - May 21, 2010

I'm trying to achiev the same thing but am confused by "wydarzenia-lista.php". Is this something specific to esteban?

Can you give me the generic way to solve this problem?
Pod9

Re: [pod9] How to make a back link to list page the same which came?

By jarvis - May 21, 2010

Can you not use a PHP referrer. So:
<?php
$ref=@$HTTP_REFERER;

echo '<a href="$ref "> <<back </a>'; ?>

Does that help?

Re: [jarvis] How to make a back link to list page the same which came?

By pod9 - May 24, 2010

Does that not assume that they have always come from the news listing page? Sometimes they may have come from a third party link such as a search engine.
Pod9

Re: [pod9] How to make a back link to list page the same which came?

By jarvis - May 24, 2010

It will always go back to the exact previous page, i.e:

- link from Google
- Page 8 0f 15 (for example) of your listings page

Does that help? Best bet is to try it & see if it does what you're after!

Cheers

Re: [jarvis] How to make a back link to list page the same which came?

By pod9 - May 24, 2010

no, I want it to go back to the listing page that had the article introduction on it.
Pod9