How to correctly override the info block for an article?

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
oloccina
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Sat Oct 03, 2009 10:11 am

How to correctly override the info block for an article?

Post by oloccina » Sat Jul 14, 2018 3:55 pm

Hello,
I want to put an anchor link to my comment form showing also th etotal number of comments in the article info block.

I laready have a custom article template in
/templates/MY-TEMPLATE/html/com_content/article/default.php

and by surfing the forum/web I understood that I need to operate on this file
/layouts/joomla/content/info_block

so I created
/layouts/joomla/content/info_block_custom

but I am not sure how to call the file in my default.php template

I tried editing line 87 to

Code: Select all

<?php echo JLayoutHelper::render('joomla.content.info_block_custom', array('item' => $this->item, 'params' => $params, 'position' => 'above')); ?>
but my articles still don't show the custom code I inserted in
/layouts/joomla/content/info_block_custom

which, by the way, would be something like

Code: Select all

<dd>
							<a href="#comments"><i class="fa fa-fw fa-comments-o"></i> <span class="commentCounter" data-kt-counter><?php echo $commentCount; ?> </span><?php echo JText::_('COM_KOMENTO_COMMENTS'); ?></a>
</dd>
I know I could probably just insert this code in the default.php file directly, but I tried and I am not satisfied on how it looks on mobile devices, I'd rather have it right into the definition list of the article info, just after teh article publish date

thanks for any advice on this!
Last edited by imanickam on Sat Jul 14, 2018 4:15 pm, edited 1 time in total.
Reason: Moved the topic from the forum General Questions/New to Joomla! 3.x to the forum Joomla! 3.x Coding

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44096
Joined: Sat Apr 05, 2008 9:58 pm

Re: How to correctly override the info block for an article?

Post by Webdongle » Sat Jul 14, 2018 5:51 pm

https://docs.joomla.org/J3.x:How_to_use ... _Overrides to create the override file in the correct place
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

oloccina
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Sat Oct 03, 2009 10:11 am

Re: How to correctly override the info block for an article?

Post by oloccina » Sun Jul 15, 2018 1:00 pm

Webdongle wrote:https://docs.joomla.org/J3.x:How_to_use ... _Overrides to create the override file in the correct place
Thank you but I dont' think this applies to my case.
I know how to create an ovverride, if you read my topic I am talking about something else here.

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 30940
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: How to correctly override the info block for an article?

Post by Per Yngve Berg » Sun Jul 15, 2018 2:09 pm

Doesn't the Comment Extension have a Plugin for this?

oloccina
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Sat Oct 03, 2009 10:11 am

Re: How to correctly override the info block for an article?

Post by oloccina » Sun Jul 15, 2018 3:03 pm

Per Yngve Berg wrote:Doesn't the Comment Extension have a Plugin for this?
Nope, ther's only the option to show the total number of comments in the article list, not in the article full view. But I am also intersted in solving this to be able to modify the info block layout at will in Joomla articles.

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 30940
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: How to correctly override the info block for an article?

Post by Per Yngve Berg » Sun Jul 15, 2018 3:17 pm

Wouldn't it make more sense to modify the plugin?

oloccina
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Sat Oct 03, 2009 10:11 am

Re: How to correctly override the info block for an article?

Post by oloccina » Wed Aug 01, 2018 1:04 pm

Per Yngve Berg wrote:
Sun Jul 15, 2018 3:17 pm
Wouldn't it make more sense to modify the plugin?
Not if you want to actually override the article info block in order to make it look better

oloccina
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Sat Oct 03, 2009 10:11 am

Re: How to correctly override the info block for an article?

Post by oloccina » Thu Aug 02, 2018 1:18 pm

Ok,
this was solved thanks to Mike eco form the Joomla Dev Google Group.
Here is the solution.

To override the info block you better to place your file to :
templates/MY-TEMPLATE/html/layouts/joomla/content/info_block

And then if your file name is "custom", render your info_block and any other micro-layout inside it like this :
<?php echo JLayoutHelper::render(joomla.content.info_block.custom', array('item' => $this->item, 'params' => $params, 'position' => 'above')); ?>

You will notice that is the directory structure of the layout folder but with dots instead of slashes. So the above renders the layout :
layouts/joomla/content/info_block/custom.php


Locked

Return to “Joomla! 3.x Coding”