ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Autocrumb - Lightweight Breadcrumb Helper (ver.12.05.1)

December 09, 2009 5:58pm

Subscribe [78]
  • #196 / Apr 08, 2012 10:40am

    ardinotow

    162 posts

    Hello ;
    another question :
    I try to change the Home by the Icon

    in breadcrumb.php
    
    $config['set_home'] = '../../image/supplement/home.png';

    here is a discussion about that
    http://ellislab.com/forums/viewthread/137949/P150

    And I try the second method but the problem is word Home still appear and image disapear after when we return to the page

    $config['set_home'] = "Home";
    
    /**
     * ------------------------
     * Config: attribute home
     * ------------------------
     * Default value:
     * $config['attr_home'] = array();
     * 
     * Apply attribute to initial or home link, e.g: 
     * $config['attr_home'] = array('style' => 'text-decoration:none', 'class' = 'home_breadcrumb');
     * Only work if unlink_home is set to FALSE
     */
    $config['attr_home'] = array('class' => 'home_breadcrumb');
    
    in css 
    .home_breadcrumb{
        background-image: url(../image/supplement/home.png);
        background-repeat: no-repeat;
       
    }

    thanks

    First, you have to make sure that unlink_home is set to FALSE then everything else is depends on what you have wrote on .home_breadcrumb on your css.

  • #197 / Apr 25, 2012 5:12pm

    ChrisMiller

    46 posts

    Just a submission, did this hack to work with my site figured I would share. I needed to replace certain uri segments on different controllers so I customized the helper to allow you to add them as needed but still allow backwards compatibility for those that have pre-existing code. All I ask is if you use it just a list my name in the credits as a contributor.


    Allow Config Options on the fly

    /* Note addition of $config variable… */
        function set_breadcrumb($delimiter_config = '', $exclude = '', $config= array() )
        {
            $CI =& get_instance();
            $CI->load->helper('url');
            $CI->lang->load('breadcrumb');
            $CI->config->load('breadcrumb');
    
            // Load configuration
            $ci_version = $CI->config->item('codeigniter_version');
      
            /* --- Start Changes --- */
            $attr_home = ( isset( $config['attr_home'] ) 
                ? $config['attr_home'] 
                : $CI->config->item('attr_home') );
       
            $unlink_home = ( isset( $config['unlike_home'] ) 
                ? $config['unlike_home'] 
                : $CI->config->item('unlike_home') );
    
            if (empty($exclude))
            {
                $exclude = $CI->config->item('exclude');
            }
          
            $exclude_segment = ( isset( $config['exclude_segment'] ) 
                ? array_merge($CI->config->item('exclude_segment'),$config['exclude_segment']) 
                : $CI->config->item('exclude_segment') );
       
            $replacer_default = ( isset( $config['replacer'] ) 
                ? array_merge($CI->config->item('replacer'),$config['replacer']) 
                : $CI->config->item('replacer') );
            
            $replacer_embed = ( isset( $config['replacer_embed'] ) 
                ? array_merge($CI->config->item('replacer_embed'),$config['replacer_embed']) 
                : $CI->config->item('replacer_embed') );
       
            $partial_replace = ( isset( $config['partial_replace'] ) 
                ? array_merge($CI->config->item('partial_replace'),$config['partial_replace']) 
         : $CI->config->item('partial_replace') );
    
            /* --- End Changes --- */
    
            $uri = rtrim($CI->uri->uri_string(),'/');
            $uri_array_original = explode("/", $uri);

    Usage would be…

    <?php echo set_breadcrumb( '', '', array( 
        'replacer' =>array (
            'view_by_id'   => 'Viewing Listing',
            'cat'          => 'Apparatus Category'
        ) 
    ) ); ?>

    Enjoy; Happy Coding

     

  • #198 / Apr 25, 2012 5:36pm

    ChrisMiller

    46 posts

    Another Addition; Requires above code to function…

    Allow Custom Segments

    // Check for custom additions
            if ( isset( $config['include_segments'] ) ) {
            
                // Set our variable for usage
                $include_segments = $config['include_segments'];
                
                // Loop our config array
                foreach ( $include_segments AS $k => $v ) {
                    $str_link[] = $k;
                    $str_name[] = ucwords($v);
                }
            }

    Add That code above the following code:

    $str_last = $wrapper[1];
            $str = $str_first;


    And the usage would be as follows:

    <?php echo set_breadcrumb( '', '', array( 
        'include_segments' =>array (
            '/some/link/'             => 'Most Popular',
            '/some/other/link'        => 'Post Title'
        ) 
    ) ); ?>
    /blog/posts/
    Would Result in:
    Home > Blog > Posts > Most Popular > Post Title
  • #199 / Apr 26, 2012 9:08am

    ardinotow

    162 posts

    @Chris. Thanks, I appreciate your effort on this helper. I will include it on next release on first week of May (please PM me in case I forget to list your name 😛). For others, I will so happy if you guys share your links that using this helper 😊

  • #200 / May 17, 2012 8:22am

    ardinotow

    162 posts

    Chris Miller’s patch now has been push to bitbucket. Thanks Chris.

  • #201 / Jun 12, 2012 3:58am

    Bart v B

    227 posts

    Hi guy’s,
    I read this in a post here:

    - Return the breadcrumb in a list (<ul><li></li></ul>) or something else (new).

    Understandable, but how can i do the “or else” ?
    I want to have my bread crumb like this:

    <article class="breadcrumbs"><a href="http://index.html">Website Admin</a> <div class="breadcrumb_divider"></div> <a href="http://localhost/cs-hostingv2/index.php%22class=%22current%22&gtDashboard&lt/a&gt&lt/article&gt/code/preI" class="current">Home</a></div></article></div>

    How can i do this?
    thnx for the help.

  • #202 / Jun 18, 2012 1:10pm

    ardinotow

    162 posts

    @Bart v B,
    Sorry, I’ve been busy lately. Hope you already solved this problem, but if not, here is how to customise wrapper as you wanted.
    Find this config variable and change it like this:

    $config['delimiter'] = '<div class="breadcrumb_divider">|</div>';
    $config['use_wrapper'] = TRUE;
    $config['wrapper'] = '<article class="breadcrumbs">|</article>';
    $config['wrapper_inline'] = '|';
  • #203 / Jun 18, 2012 8:51pm

    cyberjunkie

    34 posts

    This is a great helper! I just started using it. It should be included CI’s core functions.  😊 Thanks!

  • #204 / Jun 27, 2012 8:54am

    Bart v B

    227 posts

    @Bart v B,
    Sorry, I’ve been busy lately. Hope you already solved this problem, but if not, here is how to customise wrapper as you wanted.
    Find this config variable and change it like this:

    @ardinotow

    No problem! I did also not have the time to work on this project.
    Thnanks for the help. I solved the problem with your help. 😊
    The only thing that i had was that there was a | in the breadcrumb.
    I did a simple str_replace() to fix that.
    So in my view code became:

    <?php echo str_replace('|', '', set_breadcrumb() ); ?>

    Greetings Bart

     

  • #205 / Jul 09, 2012 4:16am

    ndrandloop

    5 posts

    Dear Ardinotow,
    can you explain me the step to use multilanguage support?
    I have 2 language (italian, english) and 2 breadcrumb_lang.php in 2 different folders (application/language/english and application/language/italian), i have turn on multilanguage support in config and there are no replace rules.
    I have loaded also language class in controller but i see always the default crumb (italian).
    I’m forgetting something???
    Thanks!

  • #206 / Jul 10, 2012 10:34am

    ndrandloop

    5 posts

    Dear Ardinotow,
    can you explain me the step to use multilanguage support?
    I have 2 language (italian, english) and 2 breadcrumb_lang.php in 2 different folders (application/language/english and application/language/italian), i have turn on multilanguage support in config and there are no replace rules.
    I have loaded also language class in controller but i see always the default crumb (italian).
    I’m forgetting something???
    Thanks!

    Resolved! Thanks!

  • #207 / Aug 23, 2012 2:56pm

    nony

    2 posts

    You saved my day! Excellent work!
    :o)

  • #208 / Aug 24, 2012 9:12am

    ardinotow

    162 posts

    @nony Glad you like it. Thanks

  • #209 / Aug 28, 2012 1:48am

    fatangel26

    10 posts

    Thanks for helper, but i have a problem: i have data of categories table :

    id    catename      parent id
    1      phone          0
    2      laptop         0
    3      samsung        1
    4      apple          1
    5       HP            2
    6       Dell          2

    I want to display breadcrumb :
    url : “localhost/categories/display_product/1” -> breadcrumb : Home->Phone
    url : “localhost/categories/display_product/2 -> breadcrumb : Home->Laptop
    url : “localhost/categories/display_product/3 -> breadcrumb : Home->Phone->Samsung
    url : “localhost/categories/display_product/5 -> breadcrumb : Home->Laptop->Dell
    ....
    Sorry for my English :D. Help me!

  • #210 / Aug 28, 2012 4:08am

    ardinotow

    162 posts

    Hi fatangel26,

    I will not give the detail but rather I will give you the logic.
    So, here it is:
    1. The key concept is using replacer, please refer to bredcrumb config file.
    2. Another concept is you can put replacer on controller (again, please read config). This mean you can process the replacer with database, i.e:

    $this->config->load('breadcrumb');
    $prod_id = $this->uri->segment(3);
    $prod_name = $this->model_xxx->get_name($prod_id);
    $parent_name = $this->model_xxx->get_parent($prod_id);
    if ($parent_name) { // if has parent then add new breadcrumb trail
       // add & change breadcrumb (see breadcrumb config)
       $this->config->set_item('replacer_embed', array('categories'=>'', 'display_product'=>'', $prod_id=>array('/categories/display/product/'.$prod_id|$parent_name, '/categories/display/product/'.$prod_id|$prod_name));
    } else { // don't have parent so just put the product name
       $this->config->set_item('replacer_embed', array('categories'=>'', 'display_product'=>'', $prod_id=>array('/categories/display/product/'.$prod_id|$prod_name));
    }

    Hope that could make you catch the ideas.
    Please let me know your progress…

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases