Search code examples
phptypo3breadcrumbsextbase

extbase extension - howto update breadcrumbs


I created an extension with extbase which displays different content dependning on the GET parameters. Is there a way to update the breadcrumbs to reflect this?

My breadcrumbs look like this in typoscript:

temp.breadcrumb = HMENU
temp.breadcrumb {
    special = rootline
    special.range = 0|-1
    1 = TMENU
        1 {
        noBlur = 1
        wrap = <ol class="breadcrumb hidden-xs">|</ol>
        NO {
            stdWrap.crop = 26 | ...
            wrapItemAndSub = <li>|</li>||<li>|</li>||<li class="last">|</li>
            ATagTitle.field = abstract // title // description
            ATagTitle.noTrimWrap = | zur Seite: |
        }
        CUR = 1
        CUR {
            stdWrap.crop = 26 | ...
            wrapItemAndSub = <li class="active">|</li>||<li class="active">|</li>||<li class="last active">|</li>
            doNotLinkIt = 1
        }
    }
}

page.10.variables {
  breadcrumb < temp.breadcrumb
}

and in my template I call them like this:

<f:format.raw>{breadcrumb}</f:format.raw>

So they work fine on normal pages, but not for my extension scripts.


Solution

  • This is a breadcrumb navigation I did a while ago which incorporates news detail views, but you'll get an idea of how to incorporate your own tables. Please note that there is some additional markup, as it follows the Google Rich Snippet Microformat for breadcrumbs.

    lib.navi.breadcrumbs = COA
    lib.navi.breadcrumbs {
    stdWrap.wrap = <ul class="breadcrumb ">|</ul>
    
    10 = TEXT
    10 {
        value = Your Homepage
        typolink {
            parameter = 1
            ATagParams =  itemprop="url"
            ATagBeforeWrap=1
            wrap = <span itemprop="title">|</span>
        }
        wrap = <li itemscope itemtype="http://data-vocabulary.org/Breadcrumb">|<span class="divider">/</span></li>
    }
    20 = HMENU
    20 {
        special = rootline
        special.range = 1|-1
    
        1 = TMENU
        1 {
            noBlur = 1
    
            NO = 1
            NO {
                wrapItemAndSub = <li itemscope itemtype="http://data-vocabulary.org/Breadcrumb">|<span class="divider">/</span></li>
                ATagParams = itemprop="url"
                stdWrap.htmlSpecialChars = 1
                stdWrap.wrap = <span itemprop="title">|</span>
            }
    
            CUR <.NO
            CUR {
                wrapItemAndSub = <li class="active">|</li>
                doNotLinkIt = 1
                stdWrap.wrap >
            }
        }
    }
    
    # Add new if on single view
    40 = RECORDS
    40 {
        if.isTrue.data = GP:tx_news_pi1|news > 0
        dontCheckPid = 1
        tables = tx_news_domain_model_news
        source.data = GP:tx_news_pi1|news
        source.intval = 1
        conf.tx_news_domain_model_news = TEXT
        conf.tx_news_domain_model_news {
            field = title
            htmlSpecialChars = 1
        }
        wrap =  <li class="active">|</li>
    }
    }
    
    [globalVar = GP:tx_news_pi1|news > 0]
    lib.navi.breadcrumbs.20.1.CUR {
    wrapItemAndSub = <li itemscope itemtype="http://data-vocabulary.org/Breadcrumb">|<span class="divider">/</span></li>
        doNotLinkIt >
    }
    [global]
    

    It basically creates a menu and appends the news title at the end if a news uid is given (lib.navi.breadcrumbs.40).

    The condition condition afterwards changes the behaviour on the last 'real' page from HMENU to act as a normal breadcrumb link.

    You can then integrate the code in your FLUID template via:

    <f:cObject typoscriptObjectPath="lib.navi.breadcrumbs" />