Any sql guru present ?

Filed under: Joomla, PHP — Eike @ May 13, 2008 12:04 pm

Actually I don’t think it needs a guru, my problem seems pretty trivial.

I was asked to provide another ordering option for the content item module so that it would display articles in the order of the ids entered in the module settings. The query looks something like

SELECT [somestuff] FROM [thetable] WHERE id = 5 OR id = 3 OR id = 7 [somejoinsandconditions]

I want the results in the order 5-3-7 but I get of course 3-5-7 and I simply don’t know how to write an orderclause that would return the desired result.

Anyone ?

    Place Here Changes

    Filed under: Joomla, PHP, Programming — Tags: , , , — Eike @ March 8, 2008 7:19 pm

    I made a few changes to the module for J!1.5.

    • Display of section/category names should now work. They sit in elements with the class of .section and .category respectively if you want to style them with CSS.
    • I added a few more ordering options.
    • I added an option to disable plugins on the module content

    Since the old download page got a little crowded with comments I moved the download to a new page. You find it in the sidebar under the link Module for 1.5 (new), URL is http://diebesteallerzeiten.de/blog/module-15/. Please leave your comments there.

    09/03/08 Edited to add:  Plugins are now disabled by default, if you want to run plugins on the module content you  must enable them in the  module parameters.

      Now with audience participation

      Filed under: Joomla, PHP — Tags: , , — Eike @ February 6, 2008 2:00 pm

      As you can tell by my silence I’m pretty busy at the moment. But at least I managed to pack a new archive for the Place Here Module that integrates a bugfix from a guy who I only know by his moniker of n7Epsilon (sent in by reader zANavAShi). The module added sometimes a couple of empty elements to its output, that should be fixed by now. I also added a random ordering option.

        There might be a moral to this

        Filed under: PHP, Programming — Tags: , — Eike @ January 18, 2008 12:21 am

        I was considering to submit this to some site like http://thedailywtf.com , but then lousy PHP Code is too common to be newsworthy. Still….

        I occasionally help a friend with an online app that was custom-made for her some four years ago… only “custom made” in that case means that the programmer followed some strange customs when he made it. The app is written mostly in procedurale PHP code – the programmer was at least dimly aware that there is such a thing as “functions” in PHP and you will actuall find some of them in the app, provided you do not look in the file “globalfunctions.inc”, which contains more procedural code (but is included in every file so at least it’s global) . Actually I even spotted an object – despite the fact that PHP 4 had been available for some time when the thing had been written it was built around a template class written in PHP3 (fasttemplate). Yet I feel that the programmer somehow misunderstood the purpose of templates, because he has a template for every single file in the app – obviously he couldn’t work out how to highlight a menu item depending on the page content, so he copied and pasted the whole HTML code for every single menu state. Actually there are two templates for every page, because this is a multilingual app (german-english) and his way to localize the application was to copy the german files and replace the copy text with the english equivalent. This is an example of not-so-great software engineering.
        (more…)

          Ask and you shall be given…

          Filed under: PHP — Tags: , , — Eike @ November 27, 2007 10:36 pm

          at least if you ask for something that’s easy to implement. In the comments Pieter asked for a new Parameter so the ‘place here” module would display the articles according to the ordering from the article manager. I added the parameter but I feel that the ordering system should be more flexible, so I’ll think of something.

            Will work for feedback

            Filed under: PHP, Programming — Tags: , , — Eike @ October 18, 2007 8:16 pm

            Someday somebody will write a better implementation of the content item/place here module and people will go there and my fifteen minutes of fame will be over. But at the moment about 130 people per day come here to ignore my various rantings about space and scifi and other stuff and head more or less straight for the download page.

            I need to confess something: I do not actually use the module myself. I wrote the first version about one and a half years ago and it was supposed to be a throwaway thingy for a specific, now defunct project. But then people looked for something like this and started asking for features and bugfixes and I invested a bit of time to make it work (as far as possible) for everyone. But keep in mind that I do not use it myself and therefore I do not actively hunt for errors. If something doesn’t work – which happend an number of times in recent weeks, since most of the module code is more than a year old and is sometimes at odds with recent versions of Joomla – I will probably not be aware of it until you tell me. I will fix everything that is possible to fix, but you need to tell me what went wrong (and possibly include your Joomla Version, PHP Version, MySql Version and operating system in the description. And if the error occured after you changed module parameters I should know this, too).

            I’m just mentioning this because a user alerted me to an error that turned up when the module is used to display categories (apparently is occurs only with recent Joomla versions) that is so severe that I wonder how people got along with the module so far. This is hopefully fixed now.

              A new name and a bit of bugfixing

              Filed under: PHP, Programming — Tags: , , — Eike @ October 12, 2007 12:06 am

              The content item module for Joomla 1.5 has been renamed to “Place Here Module” or “mod_placehere” or whatever – the name has been suggested by a user of the module and I think it fits the bill (and frankly I don’t care if it sounds good) – the new name was needed for disambiguation, if not by anybody else then at least by me (I got regularly confused on which version I was working).

              I fixed a number of bugs (but didn’t yet add any features) and I hope that it now works better and that the errors I couldn’t reproduce will now somehow be resolved, too. Well bugs… there were a few occasions were I did not (or still do not) understand the new framework – I’m convinced it’s a thing of beauty and everything, but it means that even a trivial thing like the content item module suddenly requires a heavy investment in time and effort which, I am sure, is a sign of progress. Oh well.

              New version is at the download page (see sidebar). This has been tested with WinXP/Apache and RC3. Feedback is, as always, welcome.

                Housekeeping

                Filed under: PHP — Tags: , — Eike @ October 2, 2007 9:57 pm

                I answered a couple of open questions in the FAQ section, some of them already one or two weeks old. Sorry I couldn’t keep up faster.

                  Back to the drawing board

                  Filed under: Joomla, PHP, Programming — Tags: , , — Eike @ September 15, 2007 12:01 am

                  Thank you to all the people who provided feedback for the 1.5 modules alpha version. It turned out that the alpha has some severe bugs (for some users images don’t show up, some parameter settings are ignored etc) and is therefore for all intents and purposes useless. Even worse, with some of the bugs I have no idea how to fix them (since I can’t even reproduce them). I’m investigating the issues but I feel that I’m pretty much back to square one, so there won’t be much progress in the next days.

                    They didn’t want it good, they wanted it Thursday.

                    Filed under: PHP, Projects — Tags: , — Eike @ September 1, 2007 12:35 pm

                    Ronald Reagan allegedly said that, refering to his performances as an actor. My clients usually want good work, but sometimes speed matters even more.

                    Last week a client called to ask if I could do a website on short notice; this wednesday I finally received the graphics design, and apart from some finishing touches I completed the work by Friday (it’s due by tomorrow – it’s a site for an exhibiton that starts on sunday). The code is not bad, but I could have done better. It always hurts to have to admit that, which means I hurt a lot these days, but all in all I’m a lot more comfortable than I was at the beginning of my freelancing career, when I was constantly aiming for perfection and, most of the time, failing big time.

                    (more…)