Sep 5

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

<?xml version=“1.0″?>
<config>
<
modules>
<
Parkyeri_customPHP>
<
active>true</active>
<
codePool>local</codePool>
</
Parkyeri_customPHP>
</
modules>
</
config>

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.

<?xml version=“1.0″?>
<config>
<global>
<
blocks>
<
parkyeri_customphp>
<class>
Parkyeri_customPHP_Block</class>
</
parkyeri_customphp>
</
blocks>
</global>
</
config>

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:

<?php

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

There are lots of information in the internet which you can find about full text search syntax of MySQL. A good tutorial is of course in the MySQL’s Documentation.The other informations you find are coming from there generally.

But something is missing. How can I make regular expression search using full text search engine! As the rich web interface things and other WEB 2.0 called web sites are increasing the usage of javascript and JSON is also increasing. Most of AJAX requests are now returning JSON datas and they are formatted in the javascript.

Well as the usage of json is increased, I also thing that some people, like me, are started to keep data as json in their databases. Of course that I do not mean that instead of keeping database rows, keep json text files.

Well but as this is the thing, I’m a bit confused how to filter this data. How do you get a row with something like this in it’s json data: “foo”:”bar”.

Many will think that that’s possible like this:

SELECT * FROM foo WHERE bar LIKE ‘%”foo”:”bar”%’;

Of course that this is a solution, and it will return to you the data you want! But what about performance. You may increase this performance! This is not a linear performance increase though. When you will start to deal with then thousands of rows, the search will be slower and slower. At least this was what I was thinkinh.

Well I tried to do my own benchmark tests which you can think that they were pathetic, with my phpmyadmin and mysql 5 on my local server. My test data was a table with 2500+ plus rows and the results returning were 500+. And you know that, the execution times didn’t changed a lot. They were approximately the same. The field which I was looking had a fulltext index of course, maybe this had affected a lot. Maybe someone else will. This maybe because of the pattern I was looking for. As I was looking for json formatted data, instead of json formatting, if I had just searched ‘%bar%’ things would be different.

Any ideas?

Sep 1
Still Going on Boop
icon1 admin | icon2 Boop, OS | icon4 09 1st, 2008| icon3No Comments »

I don’t know why but I’m still working on this project of mine Boop. I guess I will change it’s name from boop to Boo Project! It sounds better.

Well but of course you expect of me to what have I done. I have setup an svn server. First it was just a local copy but now it’s worldwide open. And another thing is that I have setup a trac too. A good project management tool which is integrated with svn. It has lots of “hacks”, but I did not yet installed any of them. It seems enough for me, for now.

To install a svn server and put trac on it all you need is a debian installed computer and http://trac.edgewall.org/wiki/TracOnDebianSarge link. It’s really really helpful. I had to install 4 or 5 times svn and trac and what I learned is, you can just copy paste everything and then from trac-admin run resync command, everything goes back from the point where you have taken the backup. You have to copy paste to previous directories of course.

Wiki thing is good and it forces me to write down what I think about and what I will do about. I hope some of my friends will start working on it soon or I won’t be successful enough to finish it. But thanks tou tickets, I know what I will do.

Well I was hoping to put a demo link, and the site’s link is this but I guess it’s not ready yet. Even it’s doing much of what it’s intended for, it’s still not enough.

But keep waiting.

Aug 3

Yesterday and the day before that, we (me, my sweetheart, mom, aunt and sister) were at two different concerts one by Candan Ercetin and another by Sertab Erener.

Both are very great singers. They sing and dance and yell and make the crowd joyful. It’s really interesting a person’s psychology in a concert like that. You really yell and sing with the singer. Even if you are a person really calm and don’t enjoy of yelling or singing, you sing! And you enjoy that!

It’s like going to a football game. Or maybe going to a stadium may be more suitable. You’re not the kind of man who enjoys watching or playing football but you enjoy yelling. There are people next to you which you do not even have the slightest idea about him, but you hug him when your team scores!

Also I had a chance to took a picture with Sertab Erener and also with Beyazit Ozturk(a.k.a Beyaz) (yes we were at Fanta’s Youth Festival).

Another interesting thing was that first time, my mom and my girlfriend’s mom had met. It was a bit stressful for everybody, not just for me or my girlfriend but for both of moms too. It was a short moment and it wasn’t something that you could call it was a meeting too. But at least, they know their faces and they had a first impression about each other. Mom said, “she was like elder sister of your girlfriend and more beautiful then her”. Well, that’s a start I guess.

Jul 19
Protected: Gün Gün
icon1 admin | icon2 Günlük | icon4 07 19th, 2008| icon3Enter your password to view comments

This post is password protected. To view it please enter your password below:


Jul 14
Protected: Eskiden yazardım
icon1 admin | icon2 Günlük | icon4 07 14th, 2008| icon3Enter your password to view comments

This post is password protected. To view it please enter your password below:


Jul 10

As some of you may know Gnome Users and Developers Congress (a.k.a. GUADEC) is taking place in Istanbul, Turkey at Bahcesehir University. And on it’s 4th day, it was my first day!

I had not have too much time to join discussions but, I’m sure I’m gonna attend tomorrow in the morning too. I had signed up over the internet and, GUADEC had some great stuff to give me as an attendee. A messenger back, a GUADEC 2008 t-shirt, a notepad (moleskin copy but red and written Google on it), a lots of commercial stuff about Turkey, Fedora 9 Live DVD, Ubuntu 8.04 CD and a 4G Mandriva bootable flash disk!

I had the chance to attend only two presentations, one was about Telepathy, a network framework that can be used to create multi user chat applications and other things. While at first I was intrested, the guy who was talking was not as good as a spokesman as a geek. I did not understand much of things he talked about but It was a good thing I guess.

The second one was about Moonlight, a Linux emulation of Silverlight. It was better than the previous one. The presentator was talking better but he had experienced some issues with his laptop. Anyway, It was intresting to see a Microsoft presentation in a Linux related congress. As Novell had some contracts with Microsoft, I guess this Silverlight emulation was about this as there is a group, full time worker in Novell who only does this job. I guess it’s also about that Adobe is not yet implemented Flash in Linux too. And this gap will be filled with Moonlight. It was funny to watch animations by the way. With it’s power to use C++ API and XAML markup language, it’s intresting. You have to use Mono for easily developing it. But any editors goes. But Mono is the easiest and most powerful I guess, at least that was what the man told.

It was great too see people in the conference room using their laptops during the presentation. You can argue that this is a disrespect to the man who is talking, but It was not the case in here. We are all geeks!! I really felt that I was not alone in the world and there is a lots of people around the globe that was like me!

While listening, some light bulbs had come on my mind that, joining these kind of congress open your way and mind up. When I had gone there, I was hoping there was somethings about Online Desktops but I had mistaken and I encountered something completely differently there and I entered to the discussion which I liked it’s name and it was enlightening and enjoying to do that.

Tomorrow I will go there just for that!

Jul 6
Wanted!
icon1 admin | icon2 Off Topic, myLife.show() | icon4 07 6th, 2008| icon3No Comments »

Yesterday I have watched Wanted. Angelina Jolie was beautiful. Action was also good, with bullets flying and drawing circles and ellipses and non-linear lines was cool. Bullet time was never used like this I guess. At least bullets was not going non-linear in another movie.

Even the action was good and Morgan Freeman was really and really a great actor, the story behind was so, how to say, funny. There are a group of weavers, they find the fate, in a weavering machine and they form a brotherhood named Fraternity and they start assassinating people to protect world from chaos. The people’s name whom they kill comes from this machine (well it’s not truly a machine but don’t take that part).

In every mistakes this machine makes, there is a code and guess what, it’s binary code. They were getting 8 byte codes and finding letters from it. Thousand years ago, was there binary code? I’m not a great historian, so perhaps there is. There were great mathematician around the world, very smart people, they may have found the binary code thousands years ago. But I’m not sure that ASCII was found that time. And why to use bytes (8 bits) to find the letters?

You can say that bullets were flying in circular way, man was able to jump from one skyscraper to another and he was shooting people over there (his old weapon was really cool by the way) and a bullet (two actually) was flying miles and miles and like a missile reaching to an “X”.

Well It was a funny movie, I had fun but not much fascinated by it. I expect Kung Fu Panda to be a hit by the way!!!

Jul 6

Weburunu, also named as SanalDoku (meaning virtual texture/pattern in turkish) is a good framework for creating web sites and also a simple content management system.

It has its dead ends too of course. Even it’s a powerful tool, it’s not too easy to develop with it. You have to get some practice on it. While you practice writing code with it, you enjoy using it and fascinate with ideas in it, at least I had. Even it started to get a little older it’s still powerful and flexible.

During trainings about Weburunu I mentioned some things that can be added, since we need them but don’t have too much time to write their code or design them. These are some of my thoughts and they may take Weburunu one step ahead or it can be needles as there are some different projects going on.

Well in passing days I worked on the search part of WBU and added a template search in it. Now you are able to search in display templates and it will show you the results. It can be a useful tool or just nothing. Anyone who wants to try can try it from my home directory from any wbu website’s admin panel. Just search something and below the content results there will be template results.

One more thing that can be added is, the editing of these templates from the web browser. Without the need to open an html editor or emacs or vi, we should be able to edit these display types from admin panel. This will give us more freedom and perhaps more control over our product. Or it will just create a security hole.

Another thing is to add a form generator script to content types. Which will really take Weburunu one step ahead, and it will be really more user friendly and perhaps developer friendly. By this way we can really create content types that are different than others. How these values can be defined is a different discussion anyway, but if someone must intend to write them down, then we can discuss it anyway.

Not many people tries to change or improve the Weburunu’s core as many people try to use it as tools and not to get involved deep in it. But this will help you more to understand it and also will give more insight on how to write a framework :)

Jun 27

Well, today I was at home looking for dusty parts of my computer. I have really found a lots of good old things. I’m sure that none of you remember the old days with İsimsiz Diyar. Well, things I have found remembered me that years.

It wasn’t long ago, just 3 or 4 years ago me and a lot of my friends were running a forum site named Isimsiz Diyar. It was good old times. Now a lot of us do not see each other, but still try to contact with each other via instant messaging or other things. With some of them there are thousands of miles between us. With others just some blocks and with some others only some mouse clicks.

Well I now understands why people look at the old photos and they sigh. They remember of good old times and think of their friends and memories with them. I’m a lucky guy. What I found was not just photos, they were database backups! I was able to install a local copy of the forum on my computer and I’m uploading it for my friends to see that. I hope they will all think of old times.

« Previous Entries