Skip to main content

Posts

Showing posts from 2012

Joomla! 2.5: Multiple views, one model

Here goes MVC again: I was a bit confused that every time I created a second or third view for a component, I had to create a separate model for it. Did not make sense to me - I had the necessary algorithms in the model for the first view, did I really need to do copy & paste? I hate it! Redundancy, redundancy, redundancy. That case occurred in my current project - I created user profiles and needed an "edit" view. The data is the same, but I need to have the data in editable text fields instead of fixed labels, and maybe some other buttons here and there...  Well, some time later I realized that I just did not quite understand what Joomla! acutally means by "view".  And that there is something called "layout". Long story short: If you have a model that provides all necessary information and you just want to have a different presentation of it, just add a new .php file to your views/<yourviewname>/tmpl folder - let's call it "layo

Joomla! 2.5: Table sorting / The MVC problem.

Well, I feel kind of embarrassed that I need to write about this topic... I always thought I kind of understood MVC architecture. But this one drove me nuts: I am working on a custom article management system for my front end users. I know that there might be (for sure) extensions to accomplish this, but you know how it is... you want to do it yourself. Everything worked out fine, until I got to the point of sorting the article table (alphabetically, chronologically etc.). This, too, could be done with extensions or existing jquery / other techniques. Could be. Well, I decided to do it with the traditional Javascript / Ajax / PHP approach. Jacvascript function triggers AJAX request, AJAX request goes to controller, controller queries the database and creates an array that can be handled by the view. So far so good. But how do I get the view to reload without refreshing the entire page (which would obviously loose the sort order)? I made it as far as updating the model, but I coul

Creating a Joomla! Module Position

I know how it works. At least I did, once... I tend to forget, thus I'll write it down once and for all. Step 1: Adding the position to the correct xml file Go to your template's root folder (usually <Joomla-Root>/templates/<your-template> ) and open templateDetails.xml in a text editor. Scroll down 'til  you find <position> -tags. At the end of the row of position tags, add another one (just clone the last tag and increase the number by 1). Save. before after Step 2: Check if what you just did worked Go to your Joomla! backend. Open Extensions > Module Manager. Select a module (open the module item by clicking on it). Click "Select Position". Does the position you just created appear in the table? Good! Step 3: Name your position (optional) Now you can give your position a name. The name is what appears in brackets in the position table. Go to the <Joomla-Root>/administrator/language/<your-language> fo

"Fehlerhafter Code"

One day I tried to log in to my Joomla 1.7.1 frontend area as a member of the site. I entered the correct contact information, but on clicking "Log In" I just got a white screen with the message "Fehlerhafter Code". Google only wanted me to update the page (which needs to be done sometime, I know...) - so that was not very helpful. Suddenly I remembered that I had changed the language settings of my page some time ago - it was German before, and I changed it to English. So far, so good, but I apparently forgot to set the default language for the frontend - I removed the German language pack so that only English was left. But I did not click on the "default" star icon (needs to be yellow). Go to "Extensions" - "Language Manager" - select the tab "Installed - Site" and make sure you have a default language selected. When I returned back to the frontend, I cleared the cache and everything worked fine again...

Win 7 / App Data Folders Empty

Some time ago, I observed something strange happening to my laptop: all of my menu entries in my start menu (and "all programs" menu) vanished, the task bar icons changed into a "unknown file type" icon, and nothing but Firefox was working any more. My personal files didn't seem to be affected, except for the folder "App Data". It still had all of its folders, but they were left empty. I could literally watch the menu items disappear. I could do nothing against it. A virus? A bug? I have no clue. Very nice: all of my emails were gone, too. Of course. Including all of my vacation plans, confirmation emails etc. A very good friend of mine pointed to a free tool called " Shadow Explorer ". I learned that Windows 7 creates " Shadow Copies " of nearly everything on the computer. This tool enables you to see these copies (up to about 2 or 3 weeks in the past) and recover the files. I was able to recover most of my missing app da

Joomla / Eclipse: Use Eclipse to edit files

Even though I could use any Editor or Notepad, after some days of Joomla! I was yearning for some syntax highlighting and maybe even automatic code completion... I did some Java programming in the past, and I am really used to the Eclipse IDE. Eclipse IDE for JavaScript Web Developers seemed to be a good deal for what I was up to do, so I gave it a try. I feel kind of stupid even posting about this, but upon starting up Eclipse, I started to wonder how I would do that - being that Eclipse works with projects, and I didn't want to put all of my components into an Eclipse workspace, and I didn't want to put up a subversioning system. Turns out it is quite simple: Right-click somewhere in the package explorer,  select 'New', 'Project...'. In the dialog, open the folder 'General' and select 'Project'. Click 'Next'. For the name, I usually put the com_componentname / mod_modulename, as in my file system. But I don't think it matters.

Joomla! 2.5: Component as Article

Can you put a component on a page together with other articles? Like, for example, to have a component and a blog layout on the "Home" page? Yes, you can! There are some nice extensions that allow for this. I used the "Plugin Include Component" plugin, which is available on extensions.joomla.org . With this plugin, you simply create an article that contains a special tag, indicating the component to include. Just like this: Install the plugin and put the following code in whatever article you need it in (substitute 'componentName' and 'viewname' for your component's and view's name...). {component url='index.php?option=com_ componentName &view= viewname '}

Joomla! 2.5: Menu Items

Some time ago, I started to create my own components. Everything was working fine, but there was one thing that bugged me (even though it is not really necessary... it just looked strange): When I create a link to my component, I always ended up with something like this in my menu manager: Similar thing for the menu item type: I felt like I somehow missed something, but the tutorials did not say anything about it. After playing around for a little while, I found out that the solution actually is pretty simple: The site > views > viewname > tmpl > default.xml file specifies these texts. Joomla! will look for these keys in the language files. Thus, you just need to add some entries to the language files and voila - everything looks nice and clean, just like this: Step-By-Step: Let's assume you already created the default.xml file with contents similar to these: <?xml version="1.0" encoding="utf-8"?> <metadata>