Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

closed Categories and subcategories on question pages

0 votes
asked Jul 20, 2012 in Plugins by LikeQ&A
closed Jul 28, 2012 by LikeQ&A

i've seen that when i look the question pages i see the categorie on that a user has created a question.

But from when i've created some subcategories ( very usefull to organize better my site ) i see only the subcategory and not the relative category.

I've a lo of same subcategories for example bug or suggest that are related to every category and i'd like to see category and subcategory and not only subcategory.

The only solution is to create a lot of single category but is not so good how to have category and subcategory

Thank you
closed with the note: Solved

1 Answer

+1 vote
answered Jul 21, 2012 by Merkus

Put this in your theme or a layer where you want it to appear.


$this->output( backpath_to_breadcrumbs( $q_item['raw']['categorybackpath'] ) );


Here is the function.


function backpath_to_breadcrumbs($path) {
  $delimiter = "::"; // text placed between breadcrumbs
  $crumbs = explode("/", $path);
  $crumbs = array_reverse($crumbs);
  $previous = qa_opt("site_url"); 
  $output = "";
  foreach ( $crumbs as $crumb ) {
    $output .= ' <A HREF="'.$previous.$crumb.'" CLASS="breadcrumb" REL="nofollow">'.$crumb.'</A> '.$delimiter; 
    $previous .= $crumb."/";
  } // foreach
  $output = trim( substr($output, 0 , strlen($output) - strlen($delimiter) ) ); // remove last delimiter ::
  $output = '<SPAN CLASS="breadcrumb-list">'.$output.'</SPAN>';
  return $output;
} // function 


commented Jul 21, 2012 by LikeQ&A
Hi Merkus,
Really Thank you i'll try next week as soon as possible and i hope that it solve this problem.
commented Jul 24, 2012 by LikeQ&A
what i must insert into raw and categorybackpath on your code?

$this->output( backpath_to_breadcrumbs( $q_item['raw']['categorybackpath'] ) ); in questa riga di codice cosa devo mettere al posto di 'raw' e di 'categorybackpath'

i've tried and do not work :(

commented Jul 28, 2012 by LikeQ&A
Solved.. Thank You
commented Nov 14, 2012 by Rodrigo Bueno
Sorry, but I don't know where to put this code. You said 'in my theme'. How I do it? 'Or a layer. How I do it? Thanks.