Changing the Template for Specific Articles in Joomla

Joomla

One of the most useful features of Joomla is the ability to create a template for all of your articles.  These templates can be customized until they are just right for your pages.  However, every now and then you may have a page that you want to look different.  To accomplish this, you need to override the template.  Fortunately, the Joomla 3 Template Manager makes this process, if not incredibly easy, at least easier than it used to be.  This Joomla tutorial outlines how to override the template for a specific article.

First, you are going to need to create the override.  This is done using the Template Manager.  Login to your Joomla site and click on Extensions, Template Manager, Templates.  Now scroll down until you see the template name that you are using.  You are looking for “Template name” Details and Files.

Click on it, and then look for the folder named com_content on the right.  Click on this folder to expand it.  You should see a file named article.  This is the file that controls how the articles are laid out.  Click on it and Joomla will make a copy of the relevant files so you can edit them without worrying about messing up the original template files.

To find these duplicates, navigate to templates, yourtemplate, html, com_content, article.  You will see several files in this new article file, including default.xml, default.php, and default_links.php.

First, delete the default.xml file.

Next, rename default.php to your theme name.php.  Then rename default_links.php to your theme’s name followed by _links.php.

Note that if the template you are using already has an override created, the Template Manager will not automatically make a new articles folder.  You’ll have to copy the files over manually.  To do this, copy the two .php files (default.php and default_links.php) from the folder located at components, com_content, views, article, tmpl.  Paste these files into templates, yourtemplate, html, com_contents, article.

Now it’s time to customize your new layout.  Open your new templatename.php file in Notepad or another code editor.  This is where you will need to be familiar with .php code.  If you are, you can do just about anything you want to your page layout.  Add columns, change what is displayed and where, and change how things are displayed.  You are not constrained by how the template currently looks – whatever you do here will completely override it.

Once you’ve created the new layout, you have to make sure it’s enabled.  To do this, go to Content, Article Manager, Your Article.  You should see the Options tab.  Click on it, and then look for the line for Alternative Layout.  You will see a dropdown box that will include the names of all of the possible layouts for you to use.  Pick the one you just created.

Click on Save and Close.  That should be it.  Now navigate to the article whose template you just overrode and see how it looks.  If there is anything that looks off, you’ll need to go back into the article’s coding and fix it.  You can use this override for any number of articles.

Share it!Share on FacebookTweet about this on TwitterShare on Google+Email this to someone

Our Recommended Joomla! Web Hosting Provider

Joomla

HOSTPAPA.CA
Get a 45% Discount by using our link.

HostPapa

A popular Canadian web host which offers a one-click Joomla installation option through the included control panel (cPanel). HostPapa is our recommendation to host a Joomla website.

Leave a Reply

Your email address will not be published. Required fields are marked *