Move "show category" outside "article info block"

Everything to do with Joomla! 3.x templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
Nom Anor
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Tue Nov 20, 2012 1:02 am

Move "show category" outside "article info block"

Post by Nom Anor » Wed Oct 04, 2017 10:53 pm

I'm doing my own template based on Protostar, but there is one thing I'm unsure of how to solve.

In an article I want to display the article info block (i.e. author, creation date, published date). I also want to show the category. However, I don't want to display in the info block with all the other info, but instead above the article heading.

Please see attached images.

Would appreciate help.
You do not have the required permissions to view the files attached to this post.

User avatar
jackrabbit
Joomla! Ace
Joomla! Ace
Posts: 1473
Joined: Thu May 21, 2009 3:12 am
Location: Florida
Contact:

Re: Move "show category" outside "article info block"

Post by jackrabbit » Fri Oct 06, 2017 4:04 am

Create a template override of the layouts / joomla / content

- go to extensions > template manager
- click the name of the default template under the column labeled Template
- click the tab labeled Create Overrides
- under the column titled Layouts, click joomla > content
- the copy will be created, now click the tab labeled Editor
- Edit html/layouts/joomla/content/info_block.php
- move the lines referring to category above the element
Reset Joomla super user password and username simply | http://cmsenergizer.com/website-energy- ... d-remotely

Nom Anor
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Tue Nov 20, 2012 1:02 am

Re: Move "show category" outside "article info block"

Post by Nom Anor » Mon Oct 09, 2017 1:15 am

I've tried it out and get the most of it except the last bit.
jackrabbit wrote:Create a template override of the layouts / joomla / content

- go to extensions > template manager
- click the name of the default template under the column labeled Template
- click the tab labeled Create Overrides
- under the column titled Layouts, click joomla > content
- the copy will be created, now click the tab labeled Editor
- Edit html/layouts/joomla/content/info_block.php
- move the lines referring to category above the element
The thing is, when I want to move the category to a different location e.g. above the article title, or above full image, I have to move the following code from html/layouts/joomla/content/info_block.php to a completely different file.

Code: Select all

<?php if ($displayData['params']->get('show_category')) : ?>
    <?php echo $this->sublayout('category', $displayData); ?>
<?php endif; ?>
I've tried to copy the code to html/com_content/article/default.php, but that just doesn't seem to work. :(

User avatar
jackrabbit
Joomla! Ace
Joomla! Ace
Posts: 1473
Joined: Thu May 21, 2009 3:12 am
Location: Florida
Contact:

Re: Move "show category" outside "article info block"

Post by jackrabbit » Mon Oct 09, 2017 3:26 am

To add the category object directly to your article tmpl file, place the following wherever you need the category name and link to appear. You can add the parameter condition to remove the link if desired.

Code: Select all

<?php
$itemId = JFactory::getApplication()->getMenu()->getActive()->id;
$category = '<span class="your-styleclass">'.JText::_('COM_CONTENT_CATEGORY').'<a href="'.JRoute::_('index.php?option=com_content&view=category&id='.$this->item->catid.'&Itemid='.$this->itemId).'">'.$this->item->category_title.'</a></span>';
?>
Reset Joomla super user password and username simply | http://cmsenergizer.com/website-energy- ... d-remotely


Locked

Return to “Templates for Joomla! 3.x”