0

I would like to use absolute URL instead of relative URL as the breadcrumb link on my website. Right now, I am using Drupal 7 and Path Breadcrumb 7.x-3.0 Module. All my breadcrumbs are set by Module.

This is a sample of my breadcrumb right now.

<div id="breadcrumbs">
      <h2 class="element-invisible">You are here</h2>
      <div class="breadcrumb">
                <a href="/">Home</a> » 
                <a href="/category.html">Category</a>
      </div>
      <span class="delimiter"> &gt; </span>
      <strong>Dimmer</strong>                            
</div>

How can I make the breadcrumbs like these?

<div id="breadcrumbs">
      <h2 class="element-invisible">You are here</h2>
      <div class="breadcrumb">
                <a href="http://mywebsite.com">Home</a> » 
                <a href="http://mywebsite.com/category.html">Category</a>
      </div>
      <span class="delimiter"> &gt; </span>
      <strong>Dimmer</strong>                            
</div>

EDIT

My breadcrumb code is generated by print $breadcrumb; in the page.tpl.php file. How can I convert the breadcrumb link from Relative to Absolute in this case?

2 Answers 2

0

Using PHP code you can build absolute urls with the url function.

Example:

$url = url('/category.html', ['absolute' => TRUE]);
1
  • I am sorry that my previous question is not clear. I just edited my question. I cannot use URL function since my breadcrumb is generated by print $breadcrumb;
    – jmu
    Commented Dec 26, 2017 at 15:07
0

You shall put your html in a template and create a preprocess function where you create a variable like this:

$vars['url'] = url('/category.html', ['absolute' => TRUE]);

Then you have a variable called $url that you can use in your tamplate.

Hope it works

1
  • I am sorry that my question is not very clear. In fact, that piece of code in my question is generated by print $breadcrumb; in the page.tpl.php file. I couldn't use URL function in this situation I think.
    – jmu
    Commented Dec 26, 2017 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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