open-ecommerce.org
open-ecommerce.org

Reputation: 1814

How to hide the article at the home page in joomla 2.5

How to hide the article at the home page in joomla 2.5?

Some times you want to have your home page with out showing an empty article.

Upvotes: 1

Views: 2929

Answers (6)

Barry
Barry

Reputation: 116

Isn't this as simple as changing the menu item type from frontpage to something else? for example, change the menu module type to featured articles and then have no featured articles works for sure (it's how i accomplish this). then if i want an article on there, i just 'feature' it and voila...

Upvotes: 0

Jodancer2587
Jodancer2587

Reputation: 1

Thanks for that Lodder. Copied you code and at first it didn't work... then I saw why

 $doc = JFactoty::getDocument();

JFACTOTY had a typo

when I changed it, worked fine

Upvotes: 0

Elin
Elin

Reputation: 6770

Well, you could just make the statement conditional to not being on the home page.

Upvotes: 0

betweenbrain
betweenbrain

Reputation: 840

There are a few ways to do this, and they all depend on your specific use case.

For example, if you want to hide it only on the homepage, you can change your template to the following.

Find:

<jdoc:include type="component" />

Change it to:

$menu = & JSite::getMenu();
if ($menu->getActive() != $menu->getDefault()) {
    <jdoc:include type="component" />;
}

No need to worry about JS.

Upvotes: 3

Lodder
Lodder

Reputation: 19743

Would be best to use a PHP method rather than jQuery. You can add this code to your index.php in the template folder.

<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
        $doc = JFactoty::getDocument(); //remove if already defined
        $doc->addStyleDeclaration(" #element { display:none; } ");
}
?>

Upvotes: 0

open-ecommerce.org
open-ecommerce.org

Reputation: 1814

That is not a problem if you dont have any specific background in your template.

Otherwise you can use jquery to hide the div that contains the main body.

You can add the folowing java script to your template index.php before the tag

In this sample i also want to make active the page forum thats why i am using a switch insted of if.

    <script>
    var j = jQuery.noConflict();

    var currentPage = <?php echo("'".$_SERVER['REQUEST_URI']."'"); ?>;

    switch (currentPage) {
        case '/':
             j('#rt-mainbody').hide();
            break;
        case '/forum':
            j(".item213").addClass("active");
            break;
    }
</script>

Upvotes: 0

Related Questions