1

When I try to access an article by following a link like this
index.php?option=com_content&view=article&id=9, the post appears as expected.

However, when I use the link index.php/2-uncategorised/9-assurance, the front page appears instead of the article.

Why is this happening and how can I fix it?

my index.php code :

<?php if ($menu->getActive() == $menu->getDefault()): ?>

    <jdoc:include type="modules" name="index" style="html5" />
    <?php echo '<h1>Test</h1>' ; ?>

<?php else:  ?>

    <div class="container shadow p-2 mb-2 bg-white rounded">
       <div class="row">
           <div class="col-4"><img class="img-fluid rounded " src="templates/agmaTheme/images/demmanderDevis.jpg" /></div>
            <div class="col-8 ">
                <div class="shadow-sm bg-light rounded mb-2">
                    <div class="breadcrumbs">
            <jdoc:include type="modules" name="breadcrumbs" style="html5" />
                </div>
            </div>
            <div class="shadow-sm bg-light rounded p-1"> 
                <jdoc:include type="component" />
            </div>
        </div>
    </div>
</div>

<?php endif; ?>
1

index.php/2-uncategorised/9-assurance resolves to default menu item, therefore the condition $menu->getActive() == $menu->getDefault() is met.

I strongly advise not to hide the component. If you do, any page that resolves to default menu item will not have its content displayed. This will break part of your site's functionality.

  • so what can i do instead of hiding the component ? – TheLordOne Aug 29 '18 at 8:51
0

Joomla uses Menu Items in order to know what modules, layouts etc to display. In your case the said articles/categories do not have a menu item assigned for their view, so they will default to the home-page one (which most likely is a featured items one??).

Since you don't want to display component output in the home page, I could suggest you to make your home page menu item a Single Article menu item. Create an empty home-page article and assign it there.

Then for your Uncategorized Category (or any other categories), create a category or featured items Menu Item - you can set it to hidden if you don't want it to be displayed in your menus - and then the articles of that category will be displayed under that menu item, using it's settings.

This way the check in your template:

if ($menu->getActive() == $menu->getDefault())

will result to False, and you will have your component output for those articles.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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