I am working with a unique template index.php file and want to remove the <jdoc:include type="component" />
because I don't want to display the empty space on the home page.
2 Answers
In your index.php
, you can use the following:
<?php $menu = JFactory::getApplication()->getMenu(); ?>
<?php if ($menu->getActive() != $menu->getDefault()) : ?>
<jdoc:include type="component" />
<?php endif; ?>
All this basically does is check if the active menu item doesn't match the default menu item. If it doesn't, display the component view.
-
@Ana Please provide constructive feedback so that this volunteer can perhaps modify the advice to resolve your issue. You are welcome to edit your question to provide more information, a screenshot, and/or a link to your live site. If you wish to post your working solution, the way to do that is to post an answer (not write it as a comment). Please take the tour. If
if ($app->getMenu()->getActive()->home != 1) { ?> <jdoc:include type="component" /> <?php }
works, then post your answer. Commented Jul 19, 2019 at 14:02
@Lodder Thanks, but I had tried it and it does not work. After different test I found the solution, maybe is not a best practices but this work.
In your index.php
In line 20 before <!DOCTYPE html>
<?php
$menu = $app->getMenu();
$active = $menu->getActive();
$homeactive = $active->home;
?>
In the Body:
<?php if ($homeactive != 1) : ?>
<jdoc:include type="component" />
<?php endif; ?>