How to create an Alternative Layout for Components

In this article, we cover how to create an alternative layout for components.

In these series of exercises, we will use the Protostar template that comes with Joomla and the Content Component (com_content), but you are free to use other templates and components in a similar way.

  1. Go to Extensions > Templates > Templates
    1. Click on [TEMPLATE NAME] Details and Files
    2. Click on the CREATE OVERRIDES tab
  2. We start by creating an override for com_content > article
  3. In your HTML folder, a folder called com_content is created. Inside it, you will find another folder called article and inside this folder a default.php file.
    1. Change default.php to articlewithdisclaimer.php
    2. Add the following disclaimer right before the last DIV tag:
      Copyright@<?php echo date(‘Y’)?> The Blog. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, mechanical, electronic, photocopying, recording or otherwise without the prior written permission of the publisher.
    3. Save and Close
  4. Go to Language > Overrides to rename your Alternative Layout.
    1. Filter to English (en-GB) - Administrator.
    2. Create a new language override.
    3. The Language Constant should be written like this TPL_PROTOSTAR_COM_CONTENT_ARTICLE_LAYOUT_ARTICLEWITHDISCLAIMER
      1. TPL_PROTOSTAR - Template affected
      2. COM_CONTENT - Component affected
      3. ARTICLE_LAYOUT - Layout type affected
      4. ARTICLEWITHDISCLAIMER - Name of the file containing the Alternative Layout
    4. In the Text field type the name you want to give to your alternative layout
    5. Save and close.
  5. Go to an article then click on the Options tab
    1. Change the layout to Article with Disclaimer
    2. Save and reload the article in the front end to view changes.
Pin It

Comments powered by CComment