Croogo admin panel login issues after installation

I wanted to try out the current version of Croogo, so i downloaded the current (2012-01-29) version from Github.

During installation it seems that there is eveything fine, but i could not log into the admin panel.
The current installation script does save the default password without encryption.

I also posted it to the issue tracker at croogo.lighthouseapp.com for a quick fix.

You can also do it quickly by yourself doing the following:

go to
app/Plugin/Install/Controller/InstallController.php
find line 237 and replace
// set default password for admin
$User = ClassRegistry::init('User');
$User->id = $User->field('id', array('username' => 'admin'));
$User->saveField('password', 'password');

with this code
// set default password for admin
$user = array();
$this->User = ClassRegistry::init('User');
$user['id'] = $this->User->field('id', array('username' => 'admin'));
$user['password'] = 'password';
$this->User->save($user);

When you start the installation process again the beforeSave (where encryption happens) in the User model will be used correctly and the login into admin panel works fine.

Follow @fahad19 on twitter for more information about croogo development.

Be social ;)

Geschrieben in cakephp 2.0,croogo | Keine Kommentare

Xdebug installation, another try…

I tried several times to install xdebug on my virtual box and it never worked out right. Netbeans started the script in the browser but did not connect to the server, so it was not possible to use any functionality, like breakpoints etc.
The standard installation procedure on Ubuntu server with apt-get install php5-xdebug went fine, but the result was not.

In desperation i tried to install Xdebug manually with the tutorial found on the xdebug website.

All You have to do is copy the html source from your phpinfo(); output. You will find a tutorial on how to install Xdebug with the current version on your server. With doing so, Xdebug found its way on my server, but was not activated properly.

I successfully activated it via
apt-get install php5-xdebug
The installation went fine again, but – somehow – it does now, what it should. It seems that both ways of installation missing something the other way brought in and completed each other.

Netbeans and Xdebug are now working great together and it is unbelievable helpful.

If your installation fails over and over again, like mine did, give it a try to install it like i described. maybe it will help you, too. :)

Be social ;)

Geschrieben in php | Keine Kommentare

JSON response from controller action in CakePHP 2

We know that there is a layout for XML and AJAX response in CakePHP that did their job well. But what can we do to get an easy JSON response from a controller action?

It is easier then i thought, with the new CakeResponse.

Create your your array that you want to convert into a JSON string in your controller action and with just one line of code:

return new CakeResponse(array('body' => json_encode($array)));

No $this->set() or echo $string is needed anymore.

I use this to answer requests from an Android App and it works nice and fast. :)

Be social ;)

Geschrieben in cakephp 2.0,json | Keine Kommentare

Some new stuff for the blog

Due to a huge workload on my real-life job I was not very active on the TLB Project and did not write any blog posts.
I do not want to give up any of those things, especially not my job ;) , so I decided to start posting some random css, html and javascript stuff on this blog.
I hope you will find those things useful and leave comments for those articles. :)

Be social ;)

Geschrieben in TLB Project | Keine Kommentare

using html5 form validation with cakephp

After some reading, i decided to add HTML5 form validation in the TLB admin panel. after making the changes, i am happy i made that decision at this point, because it would be a big workload to make the changes afterwards.

First of all i had to change the doctype in the layout, so the browsers knows that we want to use HTML5.
<!DOCTYPE html>
<html>

Very easy, isn’t it? ;)

Now the form. HTML5 offers some nice stuff for validation, e.g. its possible to tell the input field, that the expected value is a number or en e-mail address. Its also possible to validate against a Regex pattern. Below is an example for an input field, that requires an email address as value.
<input name="data_email" placeholder="enter e-mail" type="email" value="" required="1">
The code we use in CakePHP to create this field with the FormHelper will look like that:
echo $this->Form->input('email',
array(
'required' => true, 
'placeholder' => 'enter e-mail',
'type' => 'email'
)
);

This will create an input field that will be checked against the logic structure of an email address. The field is also marked as required, that means, that the form, will not be be send and an error message will appear, if the field is not filled out properly.

For a more complex logic HTML5 gives us the parameter pattern, that will accept a regular expression. The code in CakePHP for a slug field could look like that:
echo $this->Form->input('slug',
array(
'pattern' => '^[a-z0-9-]+$',
'placeholder' => 'Slug',
'required' => true
)
);

Of course, I kept the validation in the model, as a fallback if the browser has no HTML5 capabilities.

The clientside validation via HTML5 will help a lot with forms, where server sided validation could take a lot of time to code. I will come up with more HTML5 during upcoming development.

Be social ;)

Geschrieben in cakephp,html5 | Keine Kommentare

submit spam and submit ham – feed akismet from admin panel

Report Ham and Spam with just a clickAfter receiving feedback from Alex in my earlier post, i decided to add the mentioned functionality also to the admin panel. With the shown code its not a big thing to send the comment or product review to the Akismet service.

Next thing is the order management. a lot of stuff to do there, but i will come back to some Akismet features like checking for correct API key or submit errors. Thanks to Alex for coming up with that. ;)

Be social ;)

Geschrieben in TLB Project | Keine Kommentare

On page search engine optimization

Search engine optimization is always important and gets more important every day with the fast growing numbers of competitors.
To make it as easy as possible for the user, the little bakery project will already provide the necessary functionality to change content in the important places.

You will be able to change product urls, titles (independent from product name), description, keywords and use the canonical URL tag to avoid penalties for duplicated content when you have one product in multiple categories.

There is no customer side frontend developed yet, so all suggestions are welcome and will find place in this project :)

Be social ;)

Geschrieben in TLB Project | Keine Kommentare

admin panel development – using Akismet for product review spam detection

During the development of the simple features i recognize that the shop needs to have a product-rating-feature. In the current stage of development its pretty easy to implement, espacially if there is no shop shop frontend yet. :)

I decided to implement Akismet as a Spam filter and found an old DataSource from Felix Geisendörfer (debuggable.com), which – even after modification related to cakephp2.0 changes – did not work as expected.

After reading some API docs on the Akismet Website i decided to take out what i need from the DataSource and add some simple code to get the SpamCheck to work.

Here is what i did to make it work. It is not very clean and has to be tuned a lot, but like i wrote above, it works and thats the most important thing right now.

Put this code in app/config/database.php
public $Akismet = array(
'datasource' => 'Akismet',
'blog' => 'http://yourblog/',
'key' => 'your_akismet_key'
);

You can download the code for the DataSource from the little bakery project on Github -> Link to the file on Github

In your Model you just call the methods you need
App::uses('HttpSocket', 'Network/Http');
$this->Http = new HttpSocket();
$this->Akismet = ConnectionManager::getDataSource('Akismet');
$data = array(
'user_ip' => $author_ip,
'user_agent' => $_SERVER['HTTP_USER_AGENT'],
'referrer' => $some_referrer,
'permalink' => $permalink,
'comment_type' => 'comment',
'comment_author' => $author_name,
'comment_author_email' => $author_email,
'comment_author_url' => $author_url,
'comment_content' => $comment_text
);
$check = $this->Akismet->checkSpam($data);

As you can see in the DataSource the return value will be true (if spam) or false (if no spam) was send against the Akismet API. The check can easily implemented on a website and, if integrated into validation process, can spammer keep away from posting their stuff through validation.

As the code is not clean, i will be happy to get some feedback from you to get it done properly. :)

Be social ;)

Geschrieben in cakephp 2.0,TLB Project | 4 Kommentare

discovering the changes in cakephp 2.0

As expected, a lot of stuff changed in the new version of CakePHP and therefore the current version is not not even in beta phase there is no tutorial in sight.

first i tried to browse through the Cake code to find out, where my mistakes are, but it shows that this is kind of wasting time, if you don’t know where to start. i just asked in IRC (server: freenode, channel: #cakephp) and was sent to the lighthouse webpage, where all tickets for the current version are managed.

You will find the projectpage here: http://cakephp.lighthouseapp.com/projects/42648-cakephp

The link for the changelog is not very useful, because its about version 1.3.x and ealier, but below this link there are all categories for version 2.0 and there are all written very good, so you will find them useful understanding the changes that are made in CakePHP 2.0.

Very useful is the information about the new Class Loader that has changed to App::uses. This took me a while until i found out about it, so you can imagine that i felt pretty happy, when i found those links ;)

That’s it pretty much for now, just wanna let you know about it, in case you did not know already. ;)

Be social ;)

Geschrieben in cakephp | Keine Kommentare

bakery development in progress

productadministration

first peek of the productadministration layout

the development of the little bakery is going forward pretty well.

first of all i am about to create a working administration panel with the functionality for the user to create orders from there manually.

Today i added basic product administration and several functions to  administrate orders. i also modified the css a little bit, but there are all based on the css cake brought with it.

This will make modification pretty easy in the future, especially when new MVC files are baked.

 

Be social ;)

Geschrieben in TLB Project | Keine Kommentare