Welcome, Guest. Please login or register.
August 29, 2008, 10:46:30 AM

Login with username, password and session length
Search:     Advanced search
Please check out the Documentation available and use the advanced forum search, before posting in the forum - thanks.
Bitte lies zuerst die Dokumentation und benutze die Advanced Forensuche, bevor Du einen neuen Beitrag erstellst - danke.
Bekijk alstublieft eerst de Documentatie en gebruik de Advanced Forum Zoekfunctie, voor dat u een post maakt in het forum - Hartelijk dank.
61304 Posts in 9886 Topics by 5887 Members
Latest Member: vunh
* Home Help Search Login Register
+  Website Baker Community Forum
|-+  English
| |-+  Archive
| | |-+  Breadcrumb module
Pages: [1] 2 Go Down Print
Author Topic: Breadcrumb module  (Read 10535 times)
sucresemoule
Pending Apprentice Baker
**
Offline Offline

Posts: 42


« on: April 18, 2005, 12:37:20 PM »

I developped a small breadcrumb module based on code by Ryan and some other code from templates and other modules...

http://goliwok.com/jm/wbaker/breadcrumb.zip

It generates (like all not cached breadcrumbs) a lot of sql queries Smiley

I will add a smarty version soon to make it faster.
Logged
Stefan
Guest
« Reply #1 on: April 18, 2005, 01:25:09 PM »

Instead of using my old create_breadcrumbs code, you should rather utilize the new page_trail sql entry. It stores the same information as $bca.
Other than that: thanks for converting it into a module!  Cheesy
Logged
Hans
Master Baker
*****
Offline Offline

Posts: 358


Email
« Reply #2 on: April 18, 2005, 02:12:27 PM »

Thanks for this nice module. I have a question. When I am on this page:
http://www.domainname.nl/wb/pages/welkom/nogmaals-welkom.php the breadcrumb shows like this:
Home  : Welkom  : Nogmaals welkom >>
I would rather have it displayed like  Home  : Welkom >>
and then comes the title of the page as I write it in wysiwyg. In most cases the "wysiwyg title" is the same as the page-title and this way I can prevent it from showing up two times.

E.G
Home  : Welkom  : Nogmaals welkom >>
Nogmaals welkom should read:

Home  : Welkom >>
Nogmaals welkom
Logged

Hans - Nijmegen - The Netherlands
sucresemoule
Pending Apprentice Baker
**
Offline Offline

Posts: 42


« Reply #3 on: April 18, 2005, 02:27:03 PM »

Quote from: Stefan
Instead of using my old create_breadcrumbs code, you should rather utilize the new page_trail sql entry. It stores the same information as $bca.
Other than that: thanks for converting it into a module!  Cheesy


Smiley

I am gonna have a look on that page_trail thing.
Logged
sucresemoule
Pending Apprentice Baker
**
Offline Offline

Posts: 42


« Reply #4 on: April 18, 2005, 03:10:04 PM »

I added an option to show or hide the current page title.

http://goliwok.com/jm/wbaker/breadcrumb.zip

Added credits to Stefan in the info.php page
Logged
Hans
Master Baker
*****
Offline Offline

Posts: 358


Email
« Reply #5 on: April 18, 2005, 03:15:17 PM »

Thank you!! Great!
Hans
Logged

Hans - Nijmegen - The Netherlands
glenn
Pending Apprentice Baker
**
Offline Offline

Posts: 17


WWW
« Reply #6 on: August 30, 2005, 04:16:12 AM »

is there any way to intregrate the breadcrumbs directrly into the template.

for example, the content is "<?php page_content(); ?>
Logged

pcwacht
Guest
« Reply #7 on: August 30, 2005, 08:39:58 AM »

Yes there is.

Copy this code to the top of your templates's index.php
Code:
<?php
function create_breadcrumbs($item) {
global $database;
global $bca;
$query_menu=$database->query("SELECT page_id,parent FROM ".TABLE_PREFIX."pages WHERE page_id = '$item'");
$page=$query_menu->fetchRow();
if ($page['parent']!=0)
create_breadcrumbs($page['parent']);
else $bca[]='0';
$bca[]=$page['page_id'];
}
function 
breadcrumbs($page_id,$sep=' > ',$tier=1,$links=true) {
if ($page_id!=0)
{
 
global $database;
global $bca;
if (sizeof($bca)==0)
  Â  Â  Â  create_breadcrumbs($page_id);
$counter=0;
foreach ($bca as $temp)
{
if ($counter>=(tier-1));
  Â  {
  Â   if ($counter>$tier)
echo $sep;
$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp");
$page=$query_menu->fetchRow();
if ($links==true AND $temp!=$page_id)
echo '<a href="'.page_link($page['link']).'">'.$page['menu_title'].'</a>';
else
  Â  echo stripslashes($page['menu_title']);
}
  Â  Â  Â  $counter++;
}
echo "\n";
}
}
?>

call it from within the template with
Code:
<?php create_breadcrumbs(); ?>
at the place you need the breadcrumb.

I don't know if this is old code. But this one works for me Wink

Have fun,
John
« Last Edit: September 15, 2005, 08:28:48 PM by pcwacht » Logged
Leigh
Pending Apprentice Baker
**
Offline Offline

Posts: 34


« Reply #8 on: August 30, 2005, 05:16:16 PM »

@John, I copy & pasted you code into my index.php, but I get the following warning:

Warning: Missing argument 1 for create_breadcrumbs() in C:\Inetpub\wwwroot\wb\templates\stylish\index.php on line 114

Could you tell me what parameter I'm missing?



Secondly, as an observation, doesn't it make sense to put a breadcrumb trail in the template, rather than as a module?
Logged
Stefan
Guest
« Reply #9 on: August 30, 2005, 05:27:20 PM »

Please look directly at my script for a full documentation.
To call it, you need to use <?php breadcrumbs(PAGE_ID); ?>
and yes, I agree, this belongs into the template. That's what it was originally meant for.
Logged
Leigh
Pending Apprentice Baker
**
Offline Offline

Posts: 34


« Reply #10 on: August 30, 2005, 05:32:28 PM »

Thanks Stefan, I was missing the documentation at the beginning of the script. All is now working.

Shouldn't your code be put in the "Completed Code Snippets" section?
« Last Edit: August 30, 2005, 05:34:40 PM by Leigh » Logged
Stefan
Guest
« Reply #11 on: August 30, 2005, 06:00:37 PM »

Well, it's not really optimal anymore as there is now a way to achieve the same result with a couple less SQL calls. I have been wanting to rewrite it all the time...
Logged
Argos
"All I Do Is Bake" Baker
*****
Offline Offline

Posts: 535


WWW Email
« Reply #12 on: September 15, 2005, 01:24:24 PM »

Stefan, I would like to have a link to home in all paths, how can I do that?

So for example:  home > item3 > subitem2
Logged

Jurgen Nijhuis
Argos Media
www.argosmedia.nl
WB sites: kwaliteitinklantcontact.nl, bruschke.nl, bereikbaarheid.nl, rondvaartijmuiden.nl, nvpit.nl, synergoscommunicatie.nl, kerncompany.nl, wijnenspijs.nl, almerehuren.nl, bakker-schilder.nl
Stefan
Guest
« Reply #13 on: September 15, 2005, 02:08:01 PM »

Just hardcode the part to the first '>'.
Logged
Argos
"All I Do Is Bake" Baker
*****
Offline Offline

Posts: 535


WWW Email
« Reply #14 on: September 15, 2005, 03:11:31 PM »

Just hardcode the part to the first '>'.

Ah! "just hardcode" smiley
Well, I already figured out that that was the place to do something, but since I am no coder I have no clue what to write there. I want the "home" to be a link too, so just write "home" after echo will not do the trick I guess. Can you please tell me what to do exactly? Please? smiley
Logged

Jurgen Nijhuis
Argos Media
www.argosmedia.nl
WB sites: kwaliteitinklantcontact.nl, bruschke.nl, bereikbaarheid.nl, rondvaartijmuiden.nl, nvpit.nl, synergoscommunicatie.nl, kerncompany.nl, wijnenspijs.nl, almerehuren.nl, bakker-schilder.nl
pcwacht
Guest
« Reply #15 on: September 15, 2005, 03:17:05 PM »

Try:
<a href="http://someplacecalledhome">Home > </a><?php breadcrumbs(PAGE_ID); ?>

or simular in your template

Have fun!

John
Logged
Argos
"All I Do Is Bake" Baker
*****
Offline Offline

Posts: 535


WWW Email
« Reply #16 on: September 15, 2005, 04:08:53 PM »

Try:
<a href="http://someplacecalledhome">Home > </a><?php breadcrumbs(PAGE_ID); ?>

or simular in your template

Quite clever and so obvious that I didn't think of that. Works nicely ofcourse, however there is one small problem: on the homepage I have now "Home > Home" smiley

So an adaptation to the breadcrumb script would be nicer...
Logged

Jurgen Nijhuis
Argos Media
www.argosmedia.nl
WB sites: kwaliteitinklantcontact.nl, bruschke.nl, bereikbaarheid.nl, rondvaartijmuiden.nl, nvpit.nl, synergoscommunicatie.nl, kerncompany.nl, wijnenspijs.nl, almerehuren.nl, bakker-schilder.nl
pcwacht
Guest
« Reply #17 on: September 15, 2005, 08:27:51 PM »

Did have a wee look at breadcrumbs script

Doesn't seem like an easy adaption

Maybe something like this might work at template level

Code:
<?php
if (PAGE_ID==1
breadcrumbs(PAGE_ID); 
else
?>
<a href="http://someplacecalledhome">Home > </a><?php breadcrumbs(PAGE_ID); ?>

Change the number 1 to whatever your Home pageid is Wink

Have fun!
John
Logged
Argos
"All I Do Is Bake" Baker
*****
Offline Offline

Posts: 535


WWW Email
« Reply #18 on: September 18, 2005, 03:08:23 AM »

Nope, that gives me 3 times "home" in a row smiley
Logged

Jurgen Nijhuis
Argos Media
www.argosmedia.nl
WB sites: kwaliteitinklantcontact.nl, bruschke.nl, bereikbaarheid.nl, rondvaartijmuiden.nl, nvpit.nl, synergoscommunicatie.nl, kerncompany.nl, wijnenspijs.nl, almerehuren.nl, bakker-schilder.nl
pcwacht
Guest
« Reply #19 on: September 18, 2005, 12:27:07 PM »

Maybe the if else need more structuring something like this:

Code:
<?php
if (PAGE_ID==1)  {
  
breadcrumbs(PAGE_ID); 
} else {
  echo 
'<a href="http://someplacecalledhome">Home > </a>'breadcrumbs(PAGE_ID); 

?>


The logic,
You need the home added to every page except for the homepage
This is what the test does,
if page equals homepage just show the breadcrumbs, if not, show home plus the breadcrumbs

It should work.

John
Logged
Pages: [1] 2 Go Up Print 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!