Page 1 of 1

Custom Blog files not rendering when using module categories

Posted: Mon Apr 08, 2024 10:21 pm
by ThorHammer
Good day everyone,

I have made a copy of Articles Blog, renamed files and edited XML file and all is working
Files location: templates/MyTemplate/HTML/com_content/category/my-files

I have set up a menu item and have my custom Blog showing on the page
On the same page I have a categories module to filter items

My problem comes when I click a category, and display the items.
Instead of categories using the modified override files, I see it using blog.php from components, so my modifications are not rendered and the modified blog files are not used in this instance.

How do I make categories module use my modified Articles Blog override files instead of using default Article Blog files?

Thank you for any help here, this behaviour has got me!

PS, loving the new Joomla 4

Re: Custom Blog files not rendering when using module categories

Posted: Tue Apr 09, 2024 1:47 am
by toivo
The name of the override folder is html, not HTML.

Re: Custom Blog files not rendering when using module categories

Posted: Tue Apr 09, 2024 9:59 am
by AMurray
To clarify, toivo means *lowercase* html, not uppercase HTML (particularly relevant to Linux-based servers.

Re: Custom Blog files not rendering when using module categories

Posted: Tue Apr 09, 2024 11:30 am
by ThorHammer
toivo wrote: Tue Apr 09, 2024 1:47 am The name of the override folder is html, not HTML.
Thanks,
That was a typo on the post, in my file system the folder is lowercase html.

Re: Custom Blog files not rendering when using module categories

Posted: Tue Apr 09, 2024 11:48 pm
by ThorHammer
Is this categories module behaviour expected or unexpected on an Article:blog page?
This would apply if someone could replicate the behaviour on J4.
Maybe it is a code bug if verified?

I am not a coder, more a tinkerer so bear with me please.
I am trying to follow instructions in the book: Developing Extensions for Joomla! 5, I am trying to gain a better understanding of J4/J5.

Re: Custom Blog files not rendering when using module categories

Posted: Wed Apr 10, 2024 1:43 am
by toivo
Did you create an override for the Categories module, mod_articles_categories or mod_articles_category? Those modules work independently of the component.

Re: Custom Blog files not rendering when using module categories

Posted: Wed Apr 10, 2024 11:14 am
by ThorHammer
toivo wrote: Wed Apr 10, 2024 1:43 am Did you create an override for the Categories module, mod_articles_categories or mod_articles_category? Those modules work independently of the component.
Thank you toivo,

to double check I recreated these steps on my website this morning as to rule out a simple mistake.

blog.php
blog.xml
blog_children.php
blog_links.php
blog_item.php

The above were all copied from 'components/com_content/tmpl/category' ;renamed with a prefix 'custom-' and placed into
templates/MyTemplate/html/com_content/category

in the XML file these lines were altered to
<layout title="custom-blog" option="custom-blog">
<message>
<![CDATA[A custom blog]]>

I have not made override changes to Categories module, mod_articles_categories or mod_articles_category

I just discovered in my case that the categories module when placed on the same page as the custom_blog forgot I was using an override and custom blog and used the blog.php in components/category.

The only solution I have at the moment is not to use the categories module with an override of this type.
I do not understand enough about Joomla 4 to resolve this.

Once again, thank you for replying.

Re: Custom Blog files not rendering when using module categories

Posted: Wed Apr 10, 2024 10:46 pm
by toivo
ThorHammer wrote: Wed Apr 10, 2024 11:14 amThe above were all copied from 'components/com_content/tmpl/category' ;renamed with a prefix 'custom-' and placed into
templates/MyTemplate/html/com_content/category
That would not have worked. The override files need to have the same name as the original files.

There is no need to create overrides manually. Follow this tutorial: Joomla 4.x: Template Overrides. Please note that when several files are copied into a subfolder of the html folder but only one of those files is modified, the other files can be deleted. That keeps the override structure as simple as possible for future maintenance and possible refactoring.

Re: Custom Blog files not rendering when using module categories

Posted: Thu Apr 11, 2024 10:25 am
by ThorHammer
toivo wrote: Wed Apr 10, 2024 10:46 pm
There is no need to create overrides manually. Follow this tutorial: Joomla 4.x: Template Overrides. Please note that when several files are copied into a subfolder of the html folder but only one of those files is modified, the other files can be deleted. That keeps the override structure as simple as possible for future maintenance and possible refactoring.
Thank you,

This is the tutorial I was following to get me this far
https://www.joomlashack.com/blog/joomla ... ry-layout/
also this
https://github.com/brianteeman/joomla-cards

From your reply I am assuming the above is most probably a hack rather than a supported method, and I'm probably walking with crutches following it, just as I ditched one crutch nearing success I had the issues and needed a wheelchair instead.

I will read the template overrides and rethink my methods to achieve a card layout for one page of the many Article type Blog pages on my project.

Maybe using CSS overrides along with 'display: none' to hide the intro text and core features like columns would be a better strategy.

I really appreciate the help, you have saved me time by abandoning the tutorial and code snippet I was using to guide me.

Re: Custom Blog files not rendering when using module categories

Posted: Fri Apr 12, 2024 5:51 am
by SharkyKZ
That tutorial is not wrong. But perhaps you have multiple category menu items and the module simply links to the one using the default layout.

Re: Custom Blog files not rendering when using module categories

Posted: Fri Apr 12, 2024 11:30 am
by ThorHammer
SharkyKZ wrote: Fri Apr 12, 2024 5:51 am That tutorial is not wrong. But perhaps you have multiple category menu items and the module simply links to the one using the default layout.
I really don't know, I have now abandoned this attempt for the time being, I am now using an override Article Blog with some conditional statements.
I used $this->params->get('blog_class') to retrieve parameters i entered at Blog->Article Class and was able to implement my changes.

I did discover this which may be of help to anyone trying Overrides and Alternative Menu Items after I had implemented my changes
https://docs.joomla.org/J4.x:Template_Layouts

I may revisit this at a later date as it's irking me, but for the time being the show must go on, and I have achieved the desired changes.

Everyone has been so helpful, thank you.