Results 1 to 15 of 15

Thread: catalog and breadcumbs

  1. #1
    User
    Join Date
    09-15-09.
    Location
    France
    Posts
    98

    Default catalog and breadcumbs

    Hi,
    I would like to transform the breadcumb of my website

    My present breadcumb is : Products > Famille > Name Page Product It's the name of pages

    I would like to have name of items : Products > Paillette > Name product

    I don't find the solutions ! !

  2. #2
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: catalog and breadcumb

    You can go to Templates in the backend, and copy and modify mod_breadcrumb.tpl to your liking.
    Magnificent beard by the way....

  3. #3
    User
    Join Date
    09-15-09.
    Location
    France
    Posts
    98

    Default Re: catalog and breadcumb

    yes but I don't know the name of the variables or items..
    how do I do? {{name_catalog::name_field}} ?
    and the links ! how to build links ?
    I'm lost ops:

  4. #4
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: catalog and breadcumb

    Sorry Tom, I don't know as I've never used Catalogue.

  5. #5
    User
    Join Date
    09-15-09.
    Location
    France
    Posts
    98

    Default Re: catalog and breadcumbs

    it's pity ! !

    nobody has a solution to change the breadcrumb in catalog reader ?

  6. #6
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: catalog and breadcumbs

    Hi Tom,

    I've had to something similar before. Here's an example:
    http://www.ralphsuttondesigns.com/3d-ar ... as-wreath/

    I had to replace the category name and the product name in the breadcrumbs.

    It's not that easy to explain (or reproduce the code) because there was some other unrelated things going as well in my code. The gist of what I did was...

    1. Use the "parseFrontendTemplate" hook to intercept the "mod_breadcrumb" template.

    2. Get the current page ID via $GLOBALS['objPage']->id to check that the current page needs to have its breadcrumb modified.

    3. Get the current catalog item alias via $this->Input->get('items') and then query my catalog table to get the item title, E.g.
    Code:
     "$row = $this->Database->preprare("SELECT title FROM " . my_catalog_table . " WHERE alias=?")->limit(1)->execute($this->Input->get('items'))->row();
    4. Use str_replace() to replace the page title with the catalog item title in the breadcrumb template. E.g.
    Code:
    $strContent = str_replace($GLOBALS['objPage']->pageName, $row['title'], $strContent);
    I know I've glossed over a lot of the details, but hopefully this will at least point you in the right direction. Getting the item's category is a bit trickier, but follows the same principal.
    Brian

  7. #7
    User
    Join Date
    09-15-09.
    Location
    France
    Posts
    98

    Default Re: catalog and breadcumbs

    hi, thank you for your help

    it's not easy for me because my english is not good ! lol
    I saw it at first looks complicated!

    1) I need to work in mod_breadcrumb.html5 or ModuleBreadcrumb.php ?

    2) Are you sure to syntax :
    Code:
    $this->Database->preprare(
    Because I have error
    Code:
    Fatal error: Call to a member function preprare() on a non-object

  8. #8
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: catalog and breadcumbs

    $this->Database->prepare

  9. #9
    User
    Join Date
    09-15-09.
    Location
    France
    Posts
    98

    Default Re: catalog and breadcumbs

    thank'
    I have always a error !
    Code:
    <?php echo $row = $this->Database->prepare("SELECT ref FROM ".cat_ferroviaire." WHERE alias=?")->limit(1)->execute($this->Input->get('items'))->row(); ?>
    error
    Code:
    Fatal error: Call to a member function prepare() on a non-object in...

  10. #10
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: catalog and breadcumbs

    no idea sorry

  11. #11
    User
    Join Date
    04-10-11.
    Posts
    162

    Default Re: catalog and breadcumbs

    Where are you putting this code?

    Code:
    <?php echo $row = $this->Database->prepare("SELECT ref FROM ".cat_ferroviaire." WHERE alias=?")->limit(1)->execute($this->Input->get('items'))->row(); ?>
    For $this->Database to work you need to use it within a class that extends one of the Contao core classes or import the database class first by using $this->import('Database'). You're getting this error because $this->Database isn't an object.

    If you are trying to use the code in a template then this is what is causing the error.

    You might be able to fix it by adding $this->import('Database'); before your code. I don't know if this works within a template or not.

    Hope that helps!

  12. #12
    User
    Join Date
    09-15-09.
    Location
    France
    Posts
    98

    Default Re: catalog and breadcumbs

    no error message for the moment
    how to display the result of request ?

  13. #13
    User
    Join Date
    09-15-09.
    Location
    France
    Posts
    98

    Default Re: catalog and breadcumbs

    ok it's true...
    Code:
    <span class="active">
    <?php $this->Input->get('items');
    $this->import('Database'); 
     $objDB = $this->Database->prepare("SELECT ref FROM ".cat_ferroviaire_fr." WHERE alias=?")->limit(1)->execute($this->Input->get('items'));
     echo $objDB->ref; ?>	
    </span>
    I have a last question :
    How to display the correct breadcumbs depending on the class of modules ?
    I do 2 breadcumbs : 1 for the website and 1 to the catalog reader page's

    I'd like to add a condition based on the class..
    Code:
    if($this->cssID=='product'){...} else{}
    is it possible ? Because it's always false in my page

  14. #14
    User
    Join Date
    09-15-09.
    Location
    France
    Posts
    98

    Default Re: catalog and breadcumbs

    I found to change the breadcumbs only in page of catalog reader :
    Code:
    <?php global $objPage; ?>
    <?php if($objPage->cssClass == 'products'): ?>
    ...
    <?php else: ?>
    ...
    <?php endif; ?>
    My mod_breadcrumb.html5 :
    Code:
    <?php global $objPage; ?>
    <?php if($objPage->cssClass == 'products'): ?>
    
    <div class="<?php echo $this->class; ?> block"<?php echo $this->cssID; ?><?php if ($this->style): ?> style="<?php echo $this->style; ?>"<?php endif; ?>>
    <?php if ($this->headline): ?>
    
    <<?php echo $this->hl; ?>><?php echo $this->headline; ?></<?php echo $this->hl; ?>>
    <?php endif; ?>
    
    <?php foreach ($this->items as $item): ?>
    <?php if ($item['isActive']): ?>
    <span class="active">
    <?php $this->Input->get('items');
    $this->import('Database'); 
     $objDB = $this->Database->prepare("SELECT ref_product FROM ".cat_my_catalog." WHERE alias=?")->limit(1)->execute($this->Input->get('items'));
     echo $objDB->ref_product; ?>
    </span>
    <?php else: ?>
    "><?php echo $item['link']; ?> &#62; 
    <?php endif; ?>
    <?php endforeach; ?>
    
    </div>
    
    
    <?php else: ?>
    
    
    <div class="<?php echo $this->class; ?> block"<?php echo $this->cssID; ?><?php if ($this->style): ?> style="<?php echo $this->style; ?>"<?php endif; ?>>
    <?php if ($this->headline): ?>
    
    <<?php echo $this->hl; ?>><?php echo $this->headline; ?></<?php echo $this->hl; ?>>
    <?php endif; ?>
    
    <?php foreach ($this->items as $item): ?>
    <?php if ($item['isActive']): ?>
    <?php echo $this->cssID; ?>
    <span class="active"><?php echo $item['link']; ?></span>
    <?php else: ?>
    "><?php echo $item['link']; ?> &#62; 
    <?php endif; ?>
    <?php endforeach; ?>
    
    </div>
    
    <?php endif; ?>
    Thank you everyone for your help !

  15. #15
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: catalog and breadcumbs

    Yeah -- sorry for throwing you off track a bit. I wrote that in a rush and forgot that you either need to import 'Database', or extend a Contao class if were you doing it the hooks way. I do that a lot -- need to slow down, because I'm not really all that helpful.

    But glad you found the solution.

    Meanwhile, I did some digging and there actually is a "generateBreadcrumb" hook too that is undocumented. Looks like it passes an array of the items as well as the Breadcrumb object, and wants an array of items returned.

    Very cool for future reference. I have a project now that I think I'll try that out on...
    Brian

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •