breadcrumb help

KiF

Active member
libraryXenResourceModelCategory.php

I add 'value_desc' fields. I get php error with
'value_desc' => $breadcrumb['category_description'] after 'value' => $breadcrumb['category_title'],
but with
'value_desc' => $category['category_description'] after 'value' => $category['category_title'],
it's ok.
Help, please. What else should I change?
PHP:
        foreach ($category['categoryBreadcrumb'] AS $catId => $breadcrumb)
        {
            $breadcrumbs[$catId] = array(
                'href' => XenForo_Link::buildPublicLink('full:resources/categories', $breadcrumb),
                'value' => $breadcrumb['category_title'],
                'value_desc' => $breadcrumb['category_description']

            );
        }

        if ($includeSelf)
        {
            $breadcrumbs[$category['resource_category_id']] = array(
                'href' => XenForo_Link::buildPublicLink('full:resources/categories', $category),
                'value' => $category['category_title'],
                'value_desc' => $category['category_description']
            );
        }
 
$category['categoryBreadcrumb']['category_description'] probably doesn't exist. Verify that the data is at that level, if not, use $category['category_description'].
 
It doesn't exist. I can't use $category['category_description'] as it is not the description of $breadcrumb.
The second 'value_desc' => $category['category_description'] creates, but not the first.
I add both fields value_desc. This field is created in the second variant
(after
PHP:
'value' => $category['category_title'],
but not after first
PHP:
'value' => $breadcrumb['category_title'],
 
Last edited:
If the data doesn't exist at the point I stated it needed too, you need to add the data in. The second addition isn't at the same level as the breadcrumb data.
 
Thank you for help, @Jeremy .
Before that point the $breadcrumb is NULL.
At that point
PHP:
'href' => XenForo_Link::buildPublicLink('full:resources/categories', $breadcrumb),
'value' => $breadcrumb['category_title']
array(2) {
["href"] => string(143) "..."
["value"] => string(29) "..."

I don't understand why the field $breadcrumb['category_title'] is saved but not the $breadcrumb['category_description'].
I can't find $catId or 'full:resources/categories' anywhere else.
May be something wrong with syntax after adding the 'value_desc'. May be it should be changed?
 
$category['categoryBreadcrumb'] is an array, which contains all the bread crumbs (excluding the breadcrumb related to itself. $breadcrumb is defined for each item within that array due to the foreach() you are calling. Unless the array of breadcrumb data includes a key category_description it will not be able to populate it into the array the same as it can href and value because it has the data points necessary for those.

The second insert works because you have exited outside of the $category['categoryBreadcrumb'] array and now contains all the information related to the current category. As I said, if it does not exist within each $category['categoryBreadcrumb'] array item you will need to write custom code to add it.
 
  • Like
Reactions: KiF
Thank you Jeremy. I understood breadcrumbs a little more.

Need help with creation of this custom code...
 
Top Bottom