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.
- Go to Extensions > Templates > Templates
- Click on [TEMPLATE NAME] Details and Files
- Click on the CREATE OVERRIDES tab
- We start by creating an override for com_content > article
- 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.
- Change default.php to articlewithdisclaimer.php
- 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.
- Save and Close
- Go to Language > Overrides to rename your Alternative Layout.
- Filter to English (en-GB) - Administrator.
- Create a new language override.
- The Language Constant should be written like this TPL_PROTOSTAR_COM_CONTENT_ARTICLE_LAYOUT_ARTICLEWITHDISCLAIMER
- TPL_PROTOSTAR - Template affected
- COM_CONTENT - Component affected
- ARTICLE_LAYOUT - Layout type affected
- ARTICLEWITHDISCLAIMER - Name of the file containing the Alternative Layout
- In the Text field type the name you want to give to your alternative layout
- Save and close.
- Go to an article then click on the Options tab
- Change the layout to Article with Disclaimer
- Save and reload the article in the front end to view changes.