Mtekk's Crib

Documentation

The Breadcrumb NavXT Documentation is here to provide a reference to the bcn_breadcrumb class for other developers to quickly familiarize themselves with the plug-in. This combined with comments in the plug-in’s code should allow most PHP developers to navigate through the code. Additionally, there are example code snippets that will help users style their breadcrumbs and access the class directly without the administrative interface.

Notice: This documentation is not complete. Information documenting the classes my be out of date, and users interested in the inner workings of the core classes should check out the Trac Browser for the Breadcrumb NavXT Trunk.

Table of Contents

  1. The bcn_breadcrumb Class
    1. Member Variables
    2. Member Functions
  2. The bcn_breadcrumb_trail Class
    1. Member Variables
    2. Member Functions
  3. Action Reference
  4. Code Examples
    1. CSS Styling
    2. Advanced Usage

The bcn_breadcrumb Class

Breadcrumb NavXT employees the use of objects for implementing the breadcrumb trail. This was done to group related functions in a logical manner, and to allow for the maximum flexibility for the users. The predecessor to Breadcrumb NavXT used an object and thus it has inherited this. In version 3.0 this object was reassigned into a container for an individual breadcrumb. The successor to the old bcn_breadcrumb class is known as the bcn_breadcrumb_trail class. The current prototype for bcn_breadcrumb is:

class bcn_breadcrumb
{
	var $title;
	var $linked;
	var $prefix;
	var $suffix;
	var $anchor;
	function title_trim($max_length);
};

There are five member variables and one member function at this time.

Member Variables

$title is a string variable which contains the text that the user sees for the breadcrumb.

$linked is a boolean variable which tells the display function in bcn_breadcrumb_trail whether or not to link this breadcrumb.

$prefix is a string variable which is placed before the anchor tag (if linked, otherwise before the $title variable contents), this can contain HTML or plain text.

$suffix is a string variable which is placed after the closing anchor tag (if linked, otherwise after the $title variable contents), this can contain HTML or plain text.

$anchor is a string variable which contains the opening anchor tag for the breadcrumb.

Member Functions

title_trim($max_length) accepts an integer for the input variable and will intelligently trim the $title to the nearest word and add an ellipsis at the end. If there is no break, it will cut off mid word. The $max_length variable represents the maximum number of characters in $title after the operation takes place (in this case the ellipsis character is considered three characters even though it really is only one for spacing reasons).

Pages: 1 2 3

Modified by mtekk on April 9, 2010 at 7:02 pm

Trackbacks/Pingbacks

  1. Top WordPress Plugin: Breadcrumb NavXT
  2. Documentation | Mtekk’s Crib | WpMash - WordPress News

392 Responses to “Documentation”

  • Thank you for the plug in

  • Alex

    Great Plugin Great Thanks! Im sure that what I need to do is possible but i cant find a solution. I want to hide the currently viewed post name (if its a single post that is being viewed.) Can you help me with a solution to what i seek?

  • hello. first I want to thank you for the plugin. Second, I use your plugin in my homepage. I use pretty permalink that I don’t use \category for my category. So when I use your plugin it doesn’t work as expected. Any suggestion how to erase \category from the breadcrumb link? Thank you again.

    • Iwan,

      Breadcrumb NavXT uses WP API calls for generating all permalinks, there is nothing that I can do to resolve this (unless WP is not calling filters where it should be, again).

      -John Havlik

  • Ravi Verma

    Cool Man! Great Job. It really helps me alot. Thanks dude! :)

  • H Lang

    Nice plugin.

    I do have a problem with the “home” breadcrumb. I have created a bilingual site and all links except the home pick up the “?lang=fr” or “lang=en” appropriately.

    Do you know of a way to append the appropriate language parm?

    Thanks,
    Howard

    • H Lang

      A solution I found is adding or changing the following in the Home Anchor field in the general tab.
      (Note: the syntax used here is from the qTranslate plugin)

      <a title="Go toNaviguer à %title%.” href=”%link%?lang=enfr“>

  • Dave Landon

    I have disabled the URL linkage on some parent navigation items in pages-list-plus, unfortunately the breadcrumb trails list these pages and linkage, how can I remove non-url linked pages from the breadcrumb trail?

  • Hi Dave,
    This is awesome plugins,

    I have a question, how to remove current title?
    Example:
    Default= Home>Category>Sub Category>Current Title

    I want= Home>Category>Sub Category!! <<<<Just Like that

    Please help me,
    Thanks Before!!

  • Felix

    Hi,

    first of all, thank you for this great plug-in!

    I am having troubles with listing the current category:
    My theme outputs “You are here: Home » Archive by category ‘History’”

    But I’d like to have it just like “You are here: Home » History”.

    I set the category_suffix and _prefix to ‘ ‘ as well in the config ui as also in the [opt] settings in my theme but it still shows this behaviour. Also I noticed that it does not seem to take the values I entered in the backend. What am I doin wrong?

    Thanks and keep on doing great stuff like this!

    Regards,
    Felix

    • Felix

      Sorry, I got it to work..although I still can only configure through the code. No backend editing possible…

      Thanks!

      • Felix,

        Check your calling code. To use the settings page you must call bcn_display();. Directly accessing the bcn_breadcrumb_trail class will not load settings from the database.

        -John Havlik

  • Hi! Just one short question: is there any way to include the rewrite slugs of custom post types in the output of the plugin? For example if I have a rewrite slug like: /first/second/post its just showing home/post at the moment … if I have posttypes without hierarchy.

    • Thomas,

      Permalink wise, Breadcrumb NavXT should produce the correct URL for supported page types (I’m using 100% WP API calls). At the moment, Breadcrumb NavXT does not support custom post types correctly (I’ve just begun work on it). In a few weeks the SVN Trunk version of Breadcrumb NavXT should work with custom post types. The current status on the development is “exploratory”. I need to write up my testcases for implementation, which hopefully I’ll have them done by sometime next week. Then I can begin actual development.

      -John Havlik

  • Hi John, great plugin!

    I’ve got one issue that I haven’t been able to find a solution to yet. The site I’m working on is at http://test.rainbowskylight.co.za. The site is made up of pages.

    On a main (1st level) page, eg ‘About’ or ‘Contact’, the breadcrumb displays correctly as Home – About.

    The ‘Products’ section is made up of three levels: Products – RangeSpecific item (See the drop-down menu in the Nav) When I go into any of the 2nd or 3rd level pages the breadcrumb leaves out the 1st level one (eg. Home – Standard units – Standard Rainbowlite instead of Home – Products – Standard units – Standard Rainbowlite).

    What can I do to correct this? I haven’t seen any mention of a similar problem in the comments. Could it have to do with my templates? There are a number of different page templates in use in the different levels of the site.

    • Jonno,

      So everything under products is a page, and they are all in a hierarchy? By chance do you have the products page set as you static front page (also known as “page on front”)? Also, what is the post ID for the products page (the only thing other than having products set to the page on front that could cause an issue is if the ID is 0).

      -John Havlik

      • Hi John
        The pages are in a hierarchy – the drop-down menu in the main nav on top follows that hierarchy (it just uses wp_list_pages).
        I haven’t set the home page to use a static front page, but I’m guessing my template is creating the same effect. The homepage template includes query_posts('page_id=270'); right before the loop, to just pull in the content from the Products page.
        That being the case, what should I do? Will it be something simple like adding a wp_reset_query somewhere or changing a setting, or will I need to change the template?

        • Jonno,

          Ok, I’d remove the homepage template with the query_posts('page_id=270'); and use an actual WordPress page for your frontpage (it can have a page template to spice it up as needed). See if that resolves the problem. The only static frontpage setup supported by Breadcrumb NavXT is the “page on front” method built into WordPress. Other methods could cause the problems you are experiencing.

          -John Havlik

          • Hi John
            I just went into the ‘Reading’ settings on the site, and Your latest posts was selected, but for some reason the dropdown menu for Front page: had the Products page selected, rather than just - Select -. I deselected that, and now everything’s working perfectly, even with the template unchanged, using the query_posts call.

            Anyway, all good. Thanks a lot for the help! The solution was a bit indirect, but I’d never have thought to look there!

  • Looking forward to the custom post types support :) Thanks for the great plugin.

  • Srijan Deshpande

    Hi,
    I’m facing a problem with this plugin. When I use it on a category archive page, it displays the name of the latest post in that category followed by the category name:
    Home > Latest Post > Category
    when it should be Home > Category.

    Also, on a post page, the breadcrumb trail displayed is:
    Home > Post Name > Category Name > Post Name
    when it should be Home > Category Name > Post Name.

    Why is this happening and how do I solve this problem? Please help!
    Thanks.

    • Srijan,

      What do you mean by a “category archive page”? Are you talking about an actual page, or the category archives? Do you have a secondary loop? By chance do you have a link to the affected page?

      -John Havlik

      • Srijan Deshpande

        I mean the category archives, not an actual page. I’ve based my theme on wp-framework. I don’t have a secondary loop, just the defaultloop. Here’s the link to the page: http://avantsols.com/temp/knowledge-center/
        Thanks.

        • Srijan,

          Do you have your “Page on front” and “Posts Page” specified in your WordPress options? I haven’t seen this before, and it’s kind of interesting. Have you tried disabling all other plugins to see if the problem persists?

          -John Havlik

          • Srijan Deshpande

            Yes I have them both set to http://www.avantsols.com/temp .

            I’ve tried disabling all my plugins, but the problem still persists. I’m using wordpress 3.0 btw.

          • Hmm, OK. Can you try placing var_dump($post); before the call to bcn_display(); ? Let me know the output (it won’t fix the issue but it will help me diagnose it).

            BTW, I’m traveling this week, so my responses will be delayed.

            -John Havlik

  • Srijan,

    What do you mean by a “category archive page”? Are you talking about an actual page, or the category archives? Do you have a secondary loop? By chance do you have a link to the affected page?

    -John Havlik

  • Srijan Deshpande

    Hi, Here’s the output of var_dump($post) :

    object(stdClass)#50 (24) { ["ID"]=> int(180) ["post_author"]=> string(1) “1″ ["post_date"]=> string(19) “2010-07-14 12:00:19″ ["post_date_gmt"]=> string(19) “2010-07-14 06:30:19″ ["post_content"]=> string(745) “Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto. Quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent.” ["post_title"]=> string(9) “Test Post” ["post_excerpt"]=> string(0) “” ["post_status"]=> string(7) “publish” ["comment_status"]=> string(4) “open” ["ping_status"]=> string(4) “open” ["post_password"]=> string(0) “” ["post_name"]=> string(9) “test-post” ["to_ping"]=> string(0) “” ["pinged"]=> string(0) “” ["post_modified"]=> string(19) “2010-07-14 12:00:19″ ["post_modified_gmt"]=> string(19) “2010-07-14 06:30:19″ ["post_content_filtered"]=> string(0) “” ["post_parent"]=> int(0) ["guid"]=> string(32) “http://avantsols.com/temp/?p=180″ ["menu_order"]=> int(0) ["post_type"]=> string(4) “post” ["post_mime_type"]=> string(0) “” ["comment_count"]=> string(1) “0″ ["filter"]=> string(3) “raw” }

  • Mel

    Hey John –

    Thanks so much for building this plugin, I love how easy it is to use! I’ve been successful in inserting the breadcrumb into my header, and I’m wondering if I might be able to insert it into a loop. Basically, I thought it’d be nice to echo the breadcrumb for each search result on the search results page, where people will be seeing a mix of posts and pages, and might not know where each one lives on the actual site.

    Right now, when I insert the breadcrumb function into the loop on the search results page, it simply outputs the breadcrumb of the search page itself (“Home > Search results for ‘test’ “) , rather than the unique breadcrumb of the individual search results.

    Is it possible to display the breadcrumb of a specific post within a loop, so that each post echos its own unique breadcrumb?

    Thanks John!
    -Mel

    • Mel,

      There is some stuff in the bcn_breadcrumb::fill() function that is causing this issue. I made a change in the version in the SVN Trunk, can you try that and see if it works properly (I reordered some stuff in bcn_breadcrumb::fill() and need to do some regression testing). You can find the link to the SVN Trunk version on the Breadcrumb NavXT page.

      -John Havlik

  • Andrea

    First, I think this is a great plugin, so thank you!!

    Second, I’m trying to use it on a site where I have posts within a page, and I would like the breadcrumbs on these posts to reflect the structure.

    For example, I have all newsletter posts displaying on a page called “Newsletter”, and would like the breadcrumb to be: “Home > News & Events (page) > Newsletter (page) > Specific Newsletter Title (post)” when a visitor is viewing a specific newsletter post.

    Currently, the breadcrumb trail is “Home > Newsletter (category) > Specific Newsletter Title (post)”, since I have all newsletter posts in a category called Newsletter, and I have “Post Taxonomy Display” checked and “Post Taxonomy” set to “Categories”.

    Is there a way to further customize the Post Taxonomy, so that I can show the Page and Subpages leading up to the nested Posts, instead of the current options of “Categories”, etc?

    Thanks again for writing such a great plugin!
    Andrea

    • Andrea,

      There are no such thing as nested posts :) . By default, posts are only children of the “Posts Page” (See option under Settings > Reading). You need to use some code to make them children of any other page, and if you do that you can set the taxonomy for posts to “Pages”.

      -John Havlik

  • thanks for this plugin, it looks great. i want to have it output a list and this seems to be an option in the code, but not sure how to make it happen?

    thanks so much, bodhi

  • How to give CSS to the bcn_display_list() ?

    like

    Home
    Home

  • I love this plugin!
    I’ve been able to install WP-Print to add a print page icon. I’m looking for a way to add a Bookmark icon so users can click to add the page to their favorites. All the WP plugins I find are for social bookmarks. Do you know how I can do this?
    Thanks!

Leave a Reply

You may use these (x)HTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>