Trimming the leading THE in SQL results on Joomla module Articles Category - sql

I am trying to trim the leading "the" in a query that returns the titles of articles in Joomla, so that results are displayed in alphabetical order and the leading "the", if present, is disregarded. The module responsible for this is the Article Category (which is Joomla core module) and the file I think I should modify is helper.php in modules/mod_articles_category.
I replace the following line:
$articles->setState('list.direction', $params->get('article_ordering_direction',
'ASC'));
With this:
$articles->setState('list.direction', $params->get('article_ordering_direction',
'TRIM(LEADING \'THE \' FROM a.title) ASC'));
However, if I enable the debug mode, the TRIM is not showing. SO I guess, that I need to make the change somewhere else. Sorry but I am not familiar with Joomla so don't really know where this query is coming from. Any pointer is very much appreciated.

Okay, the short answer is no, I don't believe you can modify a query from a module, just like this. I haven't worked with modules, but I have some experience with components, so I would suggest two approaches:
Try to query the database yourself from the module, not by using setState, but building the query yourself.
You can cheat. Since Joomla has already done the heavy lifting for you, you could just manipulate the result object (i.e. $list) rearranging it and stripping off whatever you don't want. I would also suggest that you treat your code as a layout override, that way you'll be able to update your site without overriding the changes you have made.

Related

Intellij IDEA SDK - How can I programmatically handle spellcheck 'typos'?

Wrote a plugin to handle some custom format stuff in yaml files that I've written for a huge project. It's a chat bot that can respond in a huge number of ways. There is a lot of slang and non-standard words in the yaml.
I don't want to disable spellchecking as I want to fix legitimate speeling errors. But the annotations under the "misspelled" slang words are conflicting with the annotations in my plugin, and causing issue.
One yaml file has 349 "typos". 10% or so are legit. The rest are slang and custom words.
I need to do one of two things. Either add those words to the dictionary (I've found the method to do that - SpellCheckManager.getInstance(project).acceptWordAsCorrect()) OR get a list of the words and create a custom dictionary from them. Both approaches require me to grab a list of all typos in the document/editor/project.
That's the part I can't find. Looked everywhere. (List of current Annotations? List of current Problems?) Googled my fingers off. Anyone able to point me in the right direction?
This is not the IDEAL solution, but it worked for my means, and I'm leaving the answer in case this is googled.
In DaemonCodeAnalyzerImpl, there is a method:
DaemonCodeAnalyzerImpl.getHighlights(Document document, HighlightSeverity minSeverity, Project project);
This returns a list of all highlights in the document. The method is Annotated with #TestOnly, and docs state that it should only be used in Test code because it breaks/shortcuts the normal way to access that. It still works in non-test code however.
Since the only thing I wanted was the strings of the typos, I pulled the list, then looped through the HighlightInfo's in the list, and pulled the .getText()s.
No danger of screwing anything up.
Then pushed all those strings into:
SpellCheckerManager.getInstance(project).acceptWordAsCorrect(word, project);
Viola! All current highlighted typos are now added to the dictionary.
Proper solution? No. Good enough for what I needed to accomplish? Yup.

VS keeps changing my camel casing

I have posted on this before, but couldn't find a simple example. Here's one. I had some code commented out. Part if it was a comment. I used un-comment to turn the code back on for testing. And so this...
'check to see if this is a "simple" struct that has only basic types inside, not additional embedded type 5's
Turned into this...
check to see if this Is a "simple" struct that has only basic types inside, Not additional embedded type 5's
Look at the Is and Not. This isn't happening on all keywords, it appears that it's primarily Linq related terms get re-camel cased - Is, On, Where etc. And that's weird, because I don't have or use Linq in any of my projects.
This is annoying, but what is actually damaging is when this happens inside quotes. Let's say you had something like this...
'this is a "really long comment that I want to split into two lines"
Now I place my cursor in front of, say, "I" and hit return. This produces a second line with a trailing quote. Now every keyword in the entire file from that point on is re-cased, because there's an open quote confusing VS. Now my git diff is basically screwed.
Does anyone have any suggestions on what might be happening and how to turn it off?
The re-casing of keywords is a feature of "Pretty listing (reformatting) of code". This feature was less aggressive in VS versions earlier then VS2015 and did not run un-commenting a line.
To disable it go to:
Tools Menu->Options->Text Editor->Basic-> Advanced-> Editor help section
and uncheck "Pretty listing (reformatting) of code".

How to get partial view data from summernote editor?

Can I pass #Html.Partial("_PartialTest") from summernote editor?
Is there any process to set Partial View from from summernote editor?
Like:
View Example
Potentially, but you'd need something like RazorEngine to process it as a template manually and then just render the HTML somewhere in your view. If you just drop it into your view, it will be treated as text and not evaluated.
If your CMS or whatever is only going to be used by technically adept individuals this may not be an issue, but you're probably better off using something more akin to shortcodes in Wordpress. You essentially just have some syntax that a non-technical user would be capable of working with and then you replace this with the appropriate real code when rendering. You'd still need RazorEngine, but this way, if someone fat fingers the Razor syntax, you can recover more gracefully instead of just being stuck with unparsable garbage.
Also be aware that you'll need to be careful with Razor syntax in general. For example, if someone includes an # sign somewhere in the text, Razor will try to parse this and fail. As a result, you should escape any # sign in the content before actually feeding it to RazorEngine. That's another reason to use a shortcode-type system, as you'll have a real hard time trying to determine the difference between something like #Html.Partial(...) and foo#email.com and knowing which should be escaped and which shouldn't.

imageresizer outputs image paths with query strings, Pingdom Tools suggest "Remove query strings from static resources" -- how?

Can image resizer output image paths that don't contain query strings? Could not find this anywhere in documentation or googling it.
This page (http://imageresizing.net/docs/extend/extending) says that custom plugins can "Perform URL rewriting or query string expansion by registering an event handler."
Is there such a plugin, ready to be used? If so, anyone have a link?
FolderResizeSyntax is one such plugin (which simply adds and event handler to Config.Current.Pipeline.Rewrite), but you probably shouldn't use it.
Ask yourself: Why does pingdom say to remove query strings? Does it even make sense? Is there any logic behind the rule?
Query strings are often added to static resources as cache breakers and for development purposes; often they're forgotten and make it into production.
In the case of ImageResizer, they're an essential, meaningful part of the URL. Rewriting consistent name/value pairs (the querystring) into a custom URL syntax might be trendy and hip, but it adds brittleness and complexity for no actual added value.
If you have a real-world, known issues with querystrings, try the CloudFront plugin. It lets you express querystrings as image.jpg;width=100;height=100 instead of image.jpg?width=100&height=100. You still lose compatibility with all kinds of RIAPI-compliant front-end and back-end tooling, so make sure this is a real, not theoretical, issue.

Jade - way to add dynamic includes

I'd like to do something like the following within a jade template.
include page-content/#{view.template}
As this won't work I have ended up with.
-if(view.path==="/")
include ../page_content/home
-else if(view.path==="/login/")
include ../page_content/login
-else if(view.path==="/join/")
include ../page_content/join
-else if(view.path==="/user/")
include ../page_content/user
ad nauseum
I asked TJ whether it was possible, he replied
unfortunately no, they're compile-time includes, which is somewhat necessary for a few technical reasons that I wont get into but we may eventually need to add a dynamic alternative
I'm wondering if anyone has come up with any alternatives, for example using view helpers.
I'm stuck with a big config file to generate the views - and the if-else statements in the template , I know are going to come back and haunt me. :)
If this is possible using another engine, like ejs or mustache, I'd love to know.
Any ideas much appreciated.
Feels like way too much logic in the view to me. Seems like the best way to do this would be through a dynamicHelper or possibly a mixin