开发者

How to prevent Joomla from adding h1 tags in articles linked from search results and latestnews module?

In my new Joomla 1.6 website, Joomla adds an h1 tag with the text "Articles" in all articles accessed from a link in the search results of the search module. The same happens with the articles linked from the Latestnews module, but in this case, the text in the h1 added is "Home".

I d开发者_JAVA百科on't want these h1 headers! Please, any suggestion?


You can do this by modifying the template overrides for your component.

The template overrides exist under the /html/ subfolder of your template. e.g. If you wish to change the headings for search items (com_search) and you're using the rhuk_milkyway template, adjust the files found under here:

templates/rhuk_milkyway/html/com_search/

Open up the php files, (default.php) and then modify the headings by replacing the H1 tags with your own tags.

If your template does not contain any override files or folders, you can copy default the search overrides from this folder:

components/com_search/view/search/tmpl

and paste them into your template html folder:

rhuk_milkyway/html/com_search/search/

and then do the modifications as mentioned above.

You can read more on overrides here, although these articles were written for 1.5, the concepts still apply for 1.6:

  1. http://docs.joomla.org/Understanding_Output_Overrides
  2. http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core


I removed these header using JavaScript, just checking for all h1 header and searching the undesired words in their contents, than setting their display property to none.

window.onload = function() {
    var h1s = document.getElementsByTagName('h1');
    for(var i=0; i<h1s.length; i++) {
        var home = h1s[i].innerHTML.substr(2, 4);
        var articles = h1s[i].innerHTML.substr(2, 8);
        if( home == "Home" || articles =="Articles")
            h1s[i].style.display = "none";
    }
}

Although it doesn't seem a very elegant solution, in works very well and efficient in practice. Besides, if we consider these h1 as really pertaining the page content and the decision of not showing than is just a template matter, this solution is quite reasonable. The JavaScript code is as the following:

I hope it will be useful for other people. Indeed I can't understand why there aren't thousands of other Joomla! users desperately trying to get rid of theses header.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜