I will be at Free Web Days

As usual, I will be giving a talk (and I will be a wingman for another) at the Free Web Days (Özgür Web Günleri) this year at Yeditepe University. My company is one of the sponsors and we are giving like 4 talks this year which is pretty amazing :)

Of course considering that we are only making web development, it’s understandable but still pretty good. So if you will be around on 19-20 in Istanbul, we will meet you there!

Magento Beginner’s Guide

magIt’s been a long time since I have last written to my blog, it’s also longer when I have last written about Magento, the most complex, hardly understood behemoth of the PHP E-Commerce solutions. It seems that my blogs about Magento was pretty helpful for people around here and I was surprised when I’m contacted by someone from Packt Publishing about reviewing a book they had published: Magento Beginner’s Guide. You can buy directly from the publisher with additional benefits. They sent me the book and I had the time to review it because I started again to developing with Magento, a simple module which will enable to connect to banks in Turkey. And after a long pause, I was sure that this book would be a great start to find out what I missed during the my pause, how the documentation evolved and things that I was never been able to figure out. Seems like I was not wrong.
Continue reading Magento Beginner’s Guide

Keep your logs with FirePHP

If you are a web developer, It’s not possible that you did not heard of Firebug. One of the greatest extensions written for Firefox! In the recent days I finally found some spare time to handle logging for my CMS framework Boop. I had Zend Framework and I decided to use Zend_Log which had a great feature like sending your logs to FirePHP, an extension for Firebug.

Continue reading Keep your logs with FirePHP

Using Custom PHP Codes on Magento

Magento is one of the newest and awarded ecommerce application right now. And I seem to have a project launched nowadays about it.

Above the ecommerce part like adding/modifying products, it also has a built-in CMS. It looks quite useful. Not very powerful though.  It just evaluates html code and not php. In most of the time this is prefered by the way. Because of security risks and things like that. But there are also cases which you want to do if you are importing something to magento or if you are just wanting to do in a quick and dirty way!

Well, the workarounds you find are not quite good. Simply they just take the CMS code, write it to a temporary file and include it, or writing a bit complicated parser inspired from joomla/mambo. Check out here for the details of the workaround. The tutorial I’m putting here is from there to, however I will also try to write solutions to problems that I have encountered (mostly because of magento versions).

This tutorial is working for magento version 1.1.8. You can download the latest version from here.

Now open up your favorite php/xml/html editor. While it will open up, also open your magento installation folder. Magento has a lots of folders for lots of things, which I do not know why. The code part is in app/ directory as you may guess. In the app folder you will find the etc/ where there are configurations for magento generally. Our PHP Code will be a module to the Magento, so we have to go modules directory and create a new xml file, named according to your module. The syntax is like: Parkyeri_customPHP. The first part till underscore means the name of the module, int this case Parkyeri. The second part indicates the component of the module. So you may have different components in one module, in this case customPHP, If we are talking about custom codded PHP pages, so in this module named Parkyeri, there can be different pages like: About, Contact, Jobs. And these are all different components, doing different things. If we were trying to create the About page then we had to use something like Parkyeri_About. You can add all of them in the same xml file.

Open up /app/etc/modules/ and create a file named Parkyeri.xml (the name of the module) and add these lines to file:




    
        true
        local
        
    

But what this means? You declare a new module named Parkyeri to the global site by naming the file Parkyeri.xml. Then you define in the module config file that, this module has a component named customPHP. You say that this component is active and the system can find it in the app/code/local directory by looking at the codepool

As you get it now we pass to the next stage. Now open up app/code/local/Parkyeri/customPHP/etc/ and create a file named config.xml (the default configuration file name for every module.) and add these lines in it.



    
        
            
                Parkyeri_customPHP_Block
           
       
    

What does it mean? This is more of a mapping file than a configuration file. What you are doing here is to map (you may also think bind) a class named Parkyeri_customPHP_Block to a block called parkyeri_customphp. So whenever a block of type parkyeri_customphp will be called, this block will look out for the class you defined in this configuration/mapping/binding file. But also you are defining the location of the component files that you want to call. In most of the cases, you want to call a component’s block from a module. So when calling you will say that I want a component named customPHP, and a block named test and this component is under the module Parkyeri. We move on…

Now the fun part, open up app/code/local/Parkyeri/customPHP/Block and create a file named Test.php and add these lines in it:


class Parkyeri_customPHP_Block_Test extends Mage_Core_Block_Abstract
{
    protected function _toHtml()
    {
        //put here your custom PHP code with output in $html;
        //use arguments like $this->getMyParam1() , $this->getAnotherParam()
        $html = "Hello" . $this->getWorld();
        return $html;
    }
}

So, we have finally reached the part which you are most comfortable, writing code! You will write down all the code you want to evaluate in this file. The _toHtml() method is called when you call it in the cms part. A magical function just like toString(). As you may remark the name of the class, is conventional according to the location of the class. That was how the previous configuration knew where to look when mapping.

And the final part is to embed it in the CMS, this is easy part. But the part where you get dissapointed most. Add this to page you want to show your custom php code:

{{block type="parkyeri_customphp/test" world="World"}}

So, it’s obvious isn’t it? In this code part, you say that, you want to put a block here. The type of this block is parkyeri_customphp/test. So actually you want a block named test under the customphp component which also a part of parkyeri module.  But you may be curious of the rest, on what I mean by saying, world. I’m sending a parameter to the class. Remember the code where there was $this->getWorld(). This world is that world!. So the code will print out “Hello World” (without an exclamation).
So this was it! Did it worked? No I didn’t did it? The real reason that it did not worked, is because, you did not refresh the caching system!! Yes, it’s that simple! It gave me a lots of headache though, hope it won’t to you. You can disable the caching from System -> Cache Management by the way.  Better then refreshing every time :)
If you are stuck on somewhere you should really check out magento forums. There are really helpful people out there from real developers, ceos and community experts.

Update: I have tested this code sample with 1.1.8 and all works fine.

Some More Updates About Boop

Well as you may remember I was working on a cms named Boop for half a year now, at least that’s all I can remember, as I’m the only developer it takes time to get things going. I recently had time to spent with it and things are getting better and better.

Yesterday I have installed a local svn and created a repository named boop and things are getting better since then. I was really anxious about using it a version control system and as now boop had moved from a local directory to a local svn repository I will be able to follow it’s development more easily.

Recent Improvements are about refactoring and API improvements. Everybody can write down code but very few documentate that and I’m one of the few people who really cares that. Well I have documented most of the classes. There are still lots to do but at least it’s a start

I also keep try to create an easily maintainable code, so I delete and re-write some parts of it. I have decided to redesign an old legendary site of mine with it. I guess you will be informed with the beta part of it soon.

Well boop will come sooner I guess but a lot of things depend on my jobs at Parkyeri and my summer school.

Some Updates About Boop

Well if there are some people who were watching my previous blog, they may know that I was working on a blog system name “boop”. While I was struggling with WordPress, Drupal, joomla and others I had really bored and decided to write down my I own. Time has passed and I said to myself why to stop with just a “blog”! So Boop project has evolved a bit and become something more and more flexible.

Some key features of Boop is that:

  • Easy to use for everyone with complex features for experts to entertain themselves,
  • Flexible design to match your needs,
  • Create your own types,
  • Supports different language,
  • Support different themes,
  • Customize the look and feel of most things from admin panel, with basic html knowledge or use the power of FCKEditor,
  • Easily port it to any database only with changing few lines of code.

I guess these are the key points of the project. Well, I will try to create a release soon with a “blog bundle” (I’m gonna explain it later…). The only thing left is the API and a good theme which’s suitable for my “simple complex” project.

Web Technologies

I will give a web technology seminar for anyone intrested in web and internet related things. I will talk about how internet grown up, what can we do now and will show up some videos. It will be cool I guess

The seminar will at 13:00 at Kadir Has University, Fener Hall. I wait everyone who is intrested.

Check out here for additional info and more seminars.

Check here for the poster