1

I need to get the breadcrumb in the controller action because I am using the cache modules(FPC and another system externally). It cached the breadcrumb in the frontend page. With that, I would use ajax to get breadcrumb dynamically for better user experience.

The ajax is ready, there's only the breadcrumb part in my controller. Here are the codes made so far:

Ajax code:

<script type="text/javascript">
    $j(document).ready(function(){
        $j.ajax({
            url: '/fol_carousel/ajax/breadcrumb',
            type: "POST",
            dataType: "json",
            success: function(retorno){
                alert(retorno);
                console.log(retorno);
            }, error: function(x,y,z){
                console.log(x,y,z);
            }
        });
    });
</script>

Controller code:

public function breadcrumbAction(){
    echo json_encode("test");
}
0

Since the $_crumbs property is protected in Mage_Page_Block_Html_Breadcrumbs I think you'll have to extend the Block and make Magento use it instead of the default variant. In your extended block you could create a method that returns the breadcrumb data as array. Then you retrieve the breadcrumb block by doing $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs"); and call your method on the variable.

To get Magento to use your block variant you'll need to place something like the following in the config.xml of a custom module:

<config>
    <global>
        <blocks>
            <page>
                <rewrite>
                    <html_breadcrumbs>YourModule_Block_Breadcrumbs</product_list>
                </rewrite>
            </tag>
        </blocks>
    </global>
</config>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.