Tag Archives: Project

Script tag and attributes

I’ve lost precious time wondering why a Javascript code is working properly in FireFox, while on IE it’s not working at all. First thought was that the script is incompatible, but the final result was pretty stupid.

The reason:
The script tag was written this way:

<script type="application/x-javascript">
....
</script>

changing the type attribute to “text/javascript” do the magic:

<script type="text/javascript">
....
</script>

The first code is created from autocomplete snipped in Komodo Editor. So, use “text/javascript” type attribute in order to reduce headaches πŸ™‚

Strange issue with captcha field

Captcha caseWell, it’s more an observation than a real problem.

For my current CakePHP project I had to set a captcha field to a user registration form. I decided to be “creative” and I set the captcha image as background of the input field. In fact the graphical representation wasn’t bad at all. Unfortunately when it’s used, the captcha word shows wrong image and of course the result was wrong. To be correct the first attempt was always ok, but the second one (let’s say if the user decided to register again) the captcha was always wrong.

I checked everything especially after the image in Javascript library case and I couldn’t find anything suspicious.

The solution came when I removed the image from the background of the field and call it with an <img> tag. This time everything went just fine. This make me think that it’s a cache problem. I didn’t dig it deeply, because for now it’s working and as you can see it’s looking better.

So, an advise from me – never put your captcha image as background of your field, or call through css. Just use good old <img> tag instead.

Blast from the past

Hey guys,

last week I’ve worked on a project which I finished somewhere in spring of 2007 and I decided to share my experience with this post. I don’t know did you had such experience, but for me it was interesting, because working on old code is always challenge.

Basically, the project was really small one, which uses 80% of scaffolding, so really nothing complicated. Now the client wanted some extensions to the core functionality /like adding few more look-up tables and some basic reports/ and because I was the only one developer who worked on it, they ask me to do this and I agreed.

My first thought was to upgrade the core CakePHP lib to the last version, but after thinking I decided not to, because if something goes wrong /like some deprecated functions/, I need to do more work in debugging rather than focusing on the real tasks.

What I noticed while I coded?

The major one – Improvement of the console script. In the past it was in the /cake/scripts/. In the folder there were acl.php, bake.php and bake2.php, extract.php for label extraction and master bake which I never used. Now, the console script is more advanced and provide more functions. Still I am not big expert on it and I still using it for basic operations :).

Fully translated labels – it’s related to the previous one – when the code was generated with old bake script, some of the labels weren’t wrapped with __() function and especially for me it was biggest pain. Someone could tell me that there was ability to modify the templates, but I personally never did it.

The truth is that CakePHP in fact is improved a lot since then. Hopefully it will continue in this direction in the future as well.

Anyway, it was really interesting experience for me.

bInspiration.com – a small and funny application

binspiration.com Hey guys,

I am really proud to present my last project written in CakePHP – bInspiration.com.

What is all about?
bInspiration.com is a web 2.0 service which aims at helping people to get inspired. Visitors are challenged to write a sentence including 2 already given words. The application is funny way to get creative, because “filling the gaps” in a text could give unpredictable and interesting results and that’s why I thought it’s really inspiring. More you can learn from about section of the site.

How long does it take to create this
Well, I’ve decided to create this application somewhere about mid of June and in fact the time for development and design was really short, about week and a half, but due to some hardware and admin problems with my hosting, I’ve delayed the start up.

Later on, I decided to show it to some friends and the responses were not very optimistic. Most of the people didn’t get the idea of the site, so definitely there was something wrong. Apart from this I received some very good ideas for improvements and I decided to add them before going live.

The features

  • Ajax interface – the whole interface is ajaxed and it’s really easy to use it.
  • Multilingual – thanks to CakePHP i18n class, the application automatically detect the browser language preferences and translate whole site. According to this, all user’s created content will be filtered by the selected language, so users can read and write in their preferred /or at least available in the site/ language.
  • No administration – yes that’s true, and it’s feature. As a real Web2.0 application, visitors of the site are the real administrators. They can vote for each sentence in the database and from their decision the content will be promoted or completely removed from the database /two spam votes will remove the sentence from the database/.
  • Follow an author – there is possibility to browse through all authors in a specific language. It’s also possible to follow them by subscribing to their rss feed.
  • View the archive – it’s possible to browse through all sentences in the specific language.
  • Changing the given words on the fly – this was an idea from Daniel – to give possibility to switch the current fixed pair, if the visitor is not inspired by the current one.

Future plans
Well, the plans really depends from the activity of the users. πŸ™‚ But at least I have idea to make some statistical reports such as

  • Most active language
  • Most and worst sentence by language
  • Most active author
  • Most used words
  • Probably a contest πŸ™‚

and many other.

I would love to hear any comments about it.

Building cake application (Part VI)

Saturday (Day 6)

Problem with validation messages while translating
Although my native language is Bulgarian and the requirement from the client was to have this site only in Bulgarian, I’ve preferred to have it in English and to make the translation with the i18n functions of CakePHP. There are 2 reasons to do this:

1. This will give me the possibility to show you the result of all these days of coding and
2. I can reuse some part of the codes the same as I’ve used in this project

So, up to my experience having application in English is never a bad idea. πŸ™‚

You know, that the translating process is not very exciting process, but someone need to do it and because there is no one who can help me with this I’ve start the translation. Anyway. πŸ™

While translating I noticed that the most of the validation messages are not appear of the translation file. I knew this from my past experience, but I needed to find an easy and elegant solution to translate these messages instead of putting them in all views. Putting in the view you need to do this at least 2 times.
Continue reading

Building cake application (Part V)

Friday (day 5)

Constructing SQL statement for the search
Yep, today I need to finish the Profile search for the admin part. As I mentioned, the search is only by fields of experience, so there is no big and scary where clause /especially if you want to cover all cases, like splitting the words with AND, OR etc. will cause huge where with all possible combinations/.

There are 2 specific requirements here: The results need to be ordered by relevance and the report need to show fields of competence which are match to the search criteria next to each row /user/.

What does it means? Let’s say there are 2 users. First one has following skills like Java, PHP, MySQL, HTML and JavaScript, the second one knew only JavaScript and HTML, so when we search for users matching criterion PHP and HTML, the search results need to be ordered like this:

User1 – matching fields: PHP, HTML – relevance 2 criteria matched
User2 – matching fields: HTML – relevance: 1 criteria matched
and so on.

At first glance it look like I had to build huge SQL including few sub queries or functions for fetching the fields of relevance and matching fields and I was prepared for at least one day to accomplish this task, but in fact it was very fast.
Continue reading

Building cake application (Part IV)

Thursday (day 4)

Today I need to go downtown again. I am quite unhappy, because this mean that I need to work extra later on, but there are priorities, as you probably know. Here is what I’ve done today.

Working on the administration part
Today, I’ve worked on the administration part. There are some small bugs and glitches which I needed to clear in the Key look-up tables such as, stripping down the Categories functionality – this application requires only 2 levels of nesting in the Fields of experience, so allowing the extra levels will confuse the customers.

fixing some bugs in the front end as well
I’ve still have troubles with the redirects in the Auth component. I know it’s all my fault but it’s really annoying. I need to check what exactly is the problem with this. πŸ™

Adding delete all related records to the external user’s profile
Back to the admin part. I needed to implement delete all related records interface – if an admin user decide to remove an External user profile – let’s say someone try to test the application, or just an appropriate user /spammer/ this action should delete all relative records to that profile.

The problem was that I thought that key node is ‘dependent’ while the right one is ‘exclusive’. So, it’s set to true in the hasMany, hasOne etc. and if the parent record is deleted all records in the child tables are deleted too.
Continue reading

Building cake application (Part III)

Wednesday (day 3)

Adding dynamic pages
Today, I’ve decided to add some extra functionality to the application by adding a dynamic pages functionality. The main reason why I did this was because this system needed an “About the application” page as well as other pages and I’d preferred to leave this task to the clients. I also think that with small effort I am giving good impression to the client.

Instead of replacing fully the pages controller, I’ve decided to leave them due to use them for some system pages such as, “Thank for registration” and some other simple pages which are required.

Simple horizontal menu
Added a very light horizontal menu. I like it because it’s really small and works perfect for 1-2 level menus.

Using textile for formatting
I’ve decided to use textile for the formatting of the dynamic page’s content. There is a solution with behavior class, but I found a helper solution, so the installation and configuration was quite easy. I’ve also find a nice help description which briefly explains how to use textile format which I placed above of the page content field.
Continue reading

Building cake application (Part II)

Tuesday (day 2)

I really hate to start working early in the morning. I’ve always trying to delay this step by reading some news, checking mails, etc. But job need to be done and I had to go downtown, so I’ve started early today.

Building external user interface
I’ve started with the external user interface, incl. login, logout, change passwords, I’ve also decided to move fields Name and E-mail from this page to the profile page etc. Most of the things went quite well, but there were some “problems” with autoRedirect var in the Auth component. Well they weren’t real problems, but wrong redirects while the user switch from profile to another /i.e. admin to regular user/. To avoid this I’ve decided to set that variable to false, and the login redirect will be fixed to a landing page. Anyway, the application is not so big and keeping the last place is not very critical. πŸ™‚
Continue reading

Building cake application (Part I)

Monday (day 1)

In that post these posts I am going to describe my working process and problems which I’ve met during the development of small CakePHP application. I am not going to go in details neither I will post any code snippets. It will be something like diary of the working process. So, let’s start.

The scope
It’s an Experts database with 2 parts:

  • External part – where all users could register and fill their resumes and field of qualifications
  • Administration part – administrators could provide the search in the resumes and mainly in the field of knowledge.

Continue reading