Skip to main content

Posts

Joomla! 2.5 / Apache: File Downloads, docx etc.

I let my users upload files and link to them in their articles. As I want to force them to download the files directly (and don't want them to view it in the browser), I am using a file called download.php which I include in the URLs. Thus, instead of " /myfolder/myfiles/myfile.pdf " the href attribute of the link will be like " download.php?filename=/myfolder/myfiles/myfile.pdf ". In download.php I declare headers and do some things about the filename. It was always working fine for pdf or doc files, but there seemed to be something wrong with the "new" file formats of Office (docx, ppsx etc.) - if a user clicked on that file, it would be downloaded, but could not be opened (the message said something like "cannot read file"). A comparison of the original file and the downloaded file showed no difference except for one character which was not even visible. Fun fact: OpenOffice could open the file without any problems... Lots of pages su...

Joomla! 2.5: Finally - A Soulution For Applying Changes (Front End Editing)

This is about (front end) creating / editing an article. I have been looking for a way to save (apply changes) in Joomla's front end for a really long time. What I needed was just a button which would let me save changes without redirecting somewhere else... Recently I came across this page . I applied all suggested changes to my page, and it works! On the downside you need to edit Joomla core files, and the changes made to them will probably be lost after the next update...

Joomla! 2.5: Another LDAP (?) Issue

This one was really driving me crazy. Really. But we can't blame LDAP for that, at least I don't think so... We have a LDAP authentication set up which is working really well. Except when a user enters a wrong password - then he just gets a blank page. The same is the case for articles with a user restriction (user need to be logged in to view the article) - again, just a blank page. Turns out the blank page is not as blank as it seems - the source is there, including a nice error message. And a line somewhere in the head saying html{display:none;} A lot of research took me to this page , and I decided to try the following, out of some instinct: "Comment out line 823 (or thereabouts) in: libraries> joomla > html > html> behavior.php $document->addStyleDeclaration('html { display:none }'); To comment out, just add 2 slashes "//" in front of the line." Works like a charm. I am afraid the change will be undone by the next ...

Recover Joomla PhpMyAdmin MySQL Database

This morning I found myself confronted with a new problem: Our server crashed, we had to set it up again - from scratch. Fortunately, we did have some backups - the Joomla! files, and the mysql folder (on Linux: /var/lib/mysql). (We are using a Linux server with mysql and phpmyadmin.) I then tried to recover our database. What I thought: Just copy the contents from the database backup folder (mysql/joomla) to the mysql folder on the server and everything should be fine. That was what they said on the internet, too. Turns out there were only .frm files in that folder, no .myd etc. Turns out that .frm only contains the table structure. But where is my data? Everything's not lost. I found a huge file in the mysql backup folder, called ibdata1. So what you need to do now is (instructions are for Linux): - Stop your mysql service   sudo stop mysql - Copy that ibdata1 file to the /var/lib/mysql folder (consider making a backup of the existing ibdata1 file)   cd /var...

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...