Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 2334

Joomla! 4.x Coding • Re: How to order articles by field value

$
0
0
Possible but it requires a bit of development.
Well, taking 11 months to respond to all your hard work is not good enough and I apologise profusely.

I'm now back to this, but using J5.

It works (thank you) when I put the code in the Joomla Core, replacing /components/com_content/src/Model/ArticlesModel.php. Obviously, that's not the right thing to do, but I'm not sure where this file should go - or should it have a new, unique name in the same location?

Whilst the articles are now sorted by the custom field date (hooray!) I would like to limit them to articles where the custom field date is in the future. In my test site I have four articles, one of which has a custom field date in the past. I modified your code as below but nothing changed and I still see four articles.

Code:

$query->where($db->quoteName('v.id') . ' =  "1"' AND $db->quoteName('v.value') . ' > now()');
How do I link the new ArticlesModel.php with my blog override? One must refer to the other in some way. You mentioned something about a plugin. This is not something I have ever done and creating a plugin in Joomla Docs only goes up to J4 and gives an example of an existing plugin for the 'search' function. (https://docs.joomla.org/J4.x:Creating_a ... for_Joomla

I have copied the basic J5 fields.xml file as a start and tweaked it:

Code:

<?xml version="1.0" encoding="UTF-8"?><extension type="plugin" group="content" method="upgrade"><name>plg_content_events</name><author>Joomla! Project</author><creationDate>2024-02-13</creationDate><copyright>(C) 2017 Open Source Matters, Inc.</copyright><license>GNU General Public License version 2 or later; see LICENSE.txt</license><authorEmail>admin@joomla.org</authorEmail><authorUrl>www.joomla.org</authorUrl><version>5.0.2</version><description>Events Blog</description><namespace path="src">Joomla\Plugin\Content\Events</namespace><files><folder plugin="events">services</folder><folder>src</folder></files><config><fields name="params"><fieldset name="basic"></fieldset></fields></config></extension>
But when I looked further down the Joomla docs article I must admit that I am now feeling rather overwhelmed and don't know what to do next.

Statistics: Posted by GillianBPP — Tue Feb 13, 2024 6:34 pm



Viewing all articles
Browse latest Browse all 2334

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>