Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 08-19-2009 16:30:50

sydewayz
Member
Registered: 06-17-2009
Posts: 112
Website

is this possible? a 'Previous Page' Link?

I'm trying to get a previous page link set up at the request of my client. Now i know this is possible through javascript, but seeing as how there is a breadcrumbs menu already setup (which I am not using), i was hoping there was a way to set this up based on how the breadcrumbs works.

Can anyone help me with this?

Thanks,
Tim

Offline

 

#2 08-20-2009 05:52:39

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: is this possible? a 'Previous Page' Link?

If you look at the breadcrumbs include you'll see that the trail comes from the global variable named 'ecom.breadcrumbs' which is an array.  The next to last entry in the array will be the last placed visited before reaching the current page.

Offline

 

#3 08-20-2009 08:36:45

sydewayz
Member
Registered: 06-17-2009
Posts: 112
Website

Re: is this possible? a 'Previous Page' Link?

Thanks Dave. And I kind of figured that would be the case, but the issue that I'm running into now is how am I going to specify which value to print as the link? Is there anyway to say 'print second to last array value'? I have a basic understanding of php but that's about the length of it.

Regards,
Tim

Offline

 

#4 08-20-2009 09:02:07

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: is this possible? a 'Previous Page' Link?

The include gives you most of the detail you need.  To see how many elements there are in the array use count. Using what's in the include as an example:

Code:

$bc       = $this->globals('ecom.breadcrumbs');
$elements = count($bc);

The next to last one is going to be the value $elements minus 1 so what you want is the value of the link key in the element number that's the result of the count minus 1.

Code:

$bc       = $this->globals('ecom.breadcrumbs');
$elements = count($bc);
$thelink  = $bc[$elements-1]['name'];

You will of course want to add enough logic to determine whether or not you really have something to be displayed since the breadcrumb array isn't going to be available everywhere on the site.

Offline

 

#5 08-20-2009 09:21:36

sydewayz
Member
Registered: 06-17-2009
Posts: 112
Website

Re: is this possible? a 'Previous Page' Link?

Thank you so much, that's exactly what i need.

The breadcrumb array is pretty much everywhere there are products displayed IIRC.  I plan to backup the current code for the include and modify it -  so cant i just move it around in the display includes? I only want the back button in the category and product detail areas, so it should be ok.

Anyway, thanks again.

Tim

Offline

 

#6 08-20-2009 09:47:23

sydewayz
Member
Registered: 06-17-2009
Posts: 112
Website

Re: is this possible? a 'Previous Page' Link?

OK Dave. Please bear with me here, as I am pretty bad at this.

In order for me to write this myself, I need to have a better understanding of the econ.breadcrumbs array. I want to see what it outputs so I can call on the right info. Problem is, I can't find it. I browsed through all the raw database admin and I found a bunch of ECOM's but no ecom.breadcrumbs.

I really want to do this on my own, I kinda like this whole PHP thing, LOL. But I need to start from the original building blocks.

Offline

 

#7 08-20-2009 09:59:21

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: is this possible? a 'Previous Page' Link?

It's a global variable created on the fly by CCP.  To see its contents use print_r($bc) after retrieving it.

Offline

 

#8 08-20-2009 09:59:51

sydewayz
Member
Registered: 06-17-2009
Posts: 112
Website

Re: is this possible? a 'Previous Page' Link?

Ok scratch that last post I just used the print_r command and it shows up on the store pages. Sweet PHP rocks. So Im seeing it outputs two things...

'name' and 'link'.

Now it all makes sense!

Edit: Wow you posted that while I was having my epiphany sad

Last edited by sydewayz (08-20-2009 10:00:59)

Offline

 

#9 08-20-2009 11:52:43

sydewayz
Member
Registered: 06-17-2009
Posts: 112
Website

Re: is this possible? a 'Previous Page' Link?

I got it. Damn I'm so proud of myself. For anyone who wants something like this in the future, here's the code. And for some odd reason elements-1 would take me to the same page I was on, so I just used elements-2.

Code:

<?php 

$eol       = $this->globals('core.eol');
$bc        = $this->globals('ecom.breadcrumbs');
$elements  = count($bc);
$disablebc = $this->globals('core_settings.ecom.disablebreadcrumbs');
$linkgoto  = $bc[$elements-2]['link'];

if ((!(empty($bc))) && (empty($disablebc))) {

     print '<div class="storelink">' . $eol;

     print '<p><strong>Previous Page - </strong>' . $eol;

          if ($bc[$elements-2]['name'] == 'STOREHOME') 
               
               {$linkname = 'Store Home';}
          
          else 
               
               {$linkname  = $bc[$elements-2]['name'];}


    $links .= '<a href="' . $linkgoto . '" title="' . $linkname . '">' . $linkname . '</a>' . $eol;



     print $links . '</p>' . $eol . $eol;

     print '</div>' . $eol . $eol;

} // End of if statement.

?>

You can simply replace the breadcrumbs include with the code above for a nice and clean previous page link. smile

You can see it here (I only have one product up)

Now Dave, Ive got ONE more problem. The store home is not my splash page. It was quite easy to fix that in ccp6, but i cant quite figure out how to fix that in ccp7. I want the page you get when you click the above link to be my store home as well. Reason its a problem now is because when you use the previous page link i just created, it goes to the store home instead of my splash page.

Thanks for all your help so far!

Tim

Offline

 

#10 08-20-2009 14:32:01

sydewayz
Member
Registered: 06-17-2009
Posts: 112
Website

Re: is this possible? a 'Previous Page' Link?

anyone smile ?

Offline

 

#11 09-30-2009 12:45:15

chuck6478
Member
From: Missouri
Registered: 09-05-2009
Posts: 119
Website

Re: is this possible? a 'Previous Page' Link?

I would imagine element_count - 1 pointed to the current page because the array is zero relative. If you had attempted to point to element_count you probably would have thrown a bounds error.

Offline

 

#12 10-05-2009 16:52:33

seanruk
Member
Registered: 06-16-2009
Posts: 75

Re: is this possible? a 'Previous Page' Link?

Love this, I would also like to show the breadcrumbs at the footer of the page, just under the last related product add / or the 'add to cart' button. Do you know where I need to place the code to do this?


Sean


"The man who smiles when things go wrong has thought of someone to blame it on."

Offline

 

#13 10-08-2009 09:49:53

sydewayz
Member
Registered: 06-17-2009
Posts: 112
Website

Re: is this possible? a 'Previous Page' Link?

yeah, but instead of replacing the breadcrumbs include with the code i provided you would need to leave it alone and create a brand new one. then you would move the line of code that calls on the breadcrumb include to wherever you want it (by editing the prod detail display) and put your new include in its place.

Offline

 

Board footer