b2evolution Base Tag Issue

b2evolution uses a base tag to help with its template system. This is fine in modern browsers but depending on how the base tag is written IE6 may refuse to show the site at all, even going to the point of giving the user a popup warning dialogue. The fix is quite simple and I’ve implemented it in the past for both Joomla and CMS Made Simple. Now it’s time for the b2evolution version.

The following is for b2evolution v 3.3.3 and requires changing the file “inc/_core/_template.funcs.php”. After making a backup of the file, open the original and find the “base_tag” function. For me it looks like the following as default:

PHP:

<span class="amc_background#000000"><span class="amc_background#007700">function </span><span class="amc_background#0000BB">base_tag</span><span class="amc_background#007700">( </span><span class="amc_background#0000BB">$url</span><span class="amc_background#007700">, </span><span class="amc_background#0000BB">$target </span><span class="amc_background#007700">= </span><span class="amc_background#0000BB">NULL </span><span class="amc_background#007700">)</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">   {</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">      global </span><span class="amc_background#0000BB">$base_tag_set</span><span class="amc_background#007700">;</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">      </span><span class="amc_background#0000BB">$base_tag_set </span><span class="amc_background#007700">= </span><span class="amc_background#0000BB">$url</span><span class="amc_background#007700">;</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">      echo </span><span class="amc_background#DD0000">'<base href="'</span><span class="amc_background#007700">.</span><span class="amc_background#0000BB">$url</span><span class="amc_background#007700">.</span><span class="amc_background#DD0000">'"'</span><span class="amc_background#007700">;</span></span>
 
<span class="amc_background#000000"><span class="amc_background#007700">      if( !empty(</span><span class="amc_background#0000BB">$target</span><span class="amc_background#007700">) )</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">         {</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">            echo </span><span class="amc_background#DD0000">' target="'</span><span class="amc_background#007700">.</span><span class="amc_background#0000BB">$target</span><span class="amc_background#007700">.</span><span class="amc_background#DD0000">'"'</span><span class="amc_background#007700">;</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">         }</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">      echo </span><span class="amc_background#DD0000">" />n"</span><span class="amc_background#007700">;</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">   }</span></span>

Change that to the following to allow the base tag to work with IE6:

PHP:

<span class="amc_background#000000"><span class="amc_background#007700">function </span><span class="amc_background#0000BB">base_tag</span><span class="amc_background#007700">( </span><span class="amc_background#0000BB">$url</span><span class="amc_background#007700">, </span><span class="amc_background#0000BB">$target </span><span class="amc_background#007700">= </span><span class="amc_background#0000BB">NULL </span><span class="amc_background#007700">)</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">   {</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">      global </span><span class="amc_background#0000BB">$base_tag_set</span><span class="amc_background#007700">;</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">      </span><span class="amc_background#0000BB">$base_tag_set </span><span class="amc_background#007700">= </span><span class="amc_background#0000BB">$url</span><span class="amc_background#007700">;</span></span>
 
<span class="amc_background#000000"><span class="amc_background#007700">      </span><span class="amc_background#0000BB">$result </span><span class="amc_background#007700">= </span><span class="amc_background#DD0000">'<base href="'</span><span class="amc_background#007700">.</span><span class="amc_background#0000BB">$url</span><span class="amc_background#007700">.</span><span class="amc_background#DD0000">'"'</span><span class="amc_background#007700">;</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">      if( !empty(</span><span class="amc_background#0000BB">$target</span><span class="amc_background#007700">) )</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">         {</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">            </span><span class="amc_background#0000BB">$result </span><span class="amc_background#007700">.= </span><span class="amc_background#DD0000">' target="'</span><span class="amc_background#007700">.</span><span class="amc_background#0000BB">$target</span><span class="amc_background#007700">.</span><span class="amc_background#DD0000">'"'</span><span class="amc_background#007700">;</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">         }</span></span>
 
<span class="amc_background#000000"><span class="amc_background#007700">      </span><span class="amc_background#FF8000">// Taken from a fix for Drupal - <a href="http://drupal.org/node/285255">http://drupal.org/node/285255</a></span></span>
<span class="amc_background#000000"><span class="amc_background#FF8000">      </span><span class="amc_background#0000BB">$browser </span><span class="amc_background#007700">= </span><span class="amc_background#0000BB">$_SERVER</span><span class="amc_background#007700">[</span><span class="amc_background#DD0000">'HTTP_USER_AGENT'</span><span class="amc_background#007700">];</span></span>
 
<span class="amc_background#000000"><span class="amc_background#007700">      if(</span><span class="amc_background#0000BB">$msie </span><span class="amc_background#007700">= </span><span class="amc_background#0000BB">strpos</span><span class="amc_background#007700">(</span><span class="amc_background#0000BB">$browser</span><span class="amc_background#007700">, </span><span class="amc_background#DD0000">"MSIE"</span><span class="amc_background#007700">))</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">         {</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">            if(</span><span class="amc_background#0000BB">substr</span><span class="amc_background#007700">(</span><span class="amc_background#0000BB">$browser</span><span class="amc_background#007700">, </span><span class="amc_background#0000BB">$msie </span><span class="amc_background#007700">+ </span><span class="amc_background#0000BB">5</span><span class="amc_background#007700">, </span><span class="amc_background#0000BB">3</span><span class="amc_background#007700">) < </span><span class="amc_background#0000BB">7.0</span><span class="amc_background#007700">)</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">               {</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">                  </span><span class="amc_background#0000BB">$result </span><span class="amc_background#007700">.= </span><span class="amc_background#DD0000">" ></base>n"</span><span class="amc_background#007700">;</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">               }</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">            else</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">               {</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">                  </span><span class="amc_background#0000BB">$result </span><span class="amc_background#007700">.= </span><span class="amc_background#DD0000">" />n"</span><span class="amc_background#007700">;</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">               }</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">         }</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">      else</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">         {</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">            </span><span class="amc_background#0000BB">$result </span><span class="amc_background#007700">.= </span><span class="amc_background#DD0000">" />n"</span><span class="amc_background#007700">;</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">         }</span></span>
 
<span class="amc_background#000000"><span class="amc_background#007700">      echo </span><span class="amc_background#0000BB">$result</span><span class="amc_background#007700">;</span></span>
<span class="amc_background#000000"><span class="amc_background#007700">   }</span></span>

Voila! Your b2evolution blog is now viewable within IE6. Easy.

Comments: None so far...be the first!

Leave a reply

Your email address will not be published. Required fields are marked *

Kiri kiri kiri!

— Asami Yamazaki, Audition