Wrzasq.pl

Symfony2 - global templating variables in PHP renderer with ChillDevViewHelpersBundle

Wednesday, 15 January 2014, 18:45

Short time ago, while working on one of my projects i faced a problem with PHP templating engine in Symfony2 (again the same) - passing pre-defined variables to view renderer. For some reason it's not possible to define global variables for PHP templating engine. It is possible for Twig (with TwigBundle), but there is no equivalent of that for PHP. After googling for a moment and browsing some of Stack Overflow questions I ensured myself that it's not possible and that I'm not the only one who is looking for such a feature.

Tags: , , ,

» Komentarze

Symfony2 - creating adapter-dependent sub-forms

Wednesday, 11 September 2013, 19:04

I think this is quite commonly needed feature - form structure that vary depending on some other field(s). The project, on which I'm currently working, is integrated with a lot of external APIs which usually require additional per-user options for each of them. It's a SEO tool and - to pick an example - provides various indexing services integration. Some of them require API key, some require login and password, some specify different URLs. So for each of them form structure can differ. Of course you could use some conditions to pick correct structure, but it's not enough - form needs to change together with selected option. There are some partial tutorials on the web how to alternate form based on events, but it's just one part of the solution - here is more complex one.

Tags: , , , ,

» Komentarze

Symfony2 - simple, yet useful tips

Monday, 17 June 2013, 16:24

It's been a while since my last article and activity, as I was mainly concentrated on my private life and commercials projects, but even though my top commitment was updating projects dependencies on GitHub I also experimented with some different approaches for organising Symfony2 projects. I want to share some of my thoughts, so you may also benefit from using it or tell me why these ideas are stupid. I don't want to write here some obvious stuff like "write unit tests", "use Composer" etc. - you can read that in every single tutorial for Symfony2. Some of my tricks are plain simple but not obvious, some, on the other hand look strange, but saved my ass, so you can give them a try. Please excuse my a bit chaotic form (and content), but I'm writing this in my free time while commuting by train :P.

Tags: , , , ,

» Komentarze

Using Disqus in XHTML applications

Wednesday, 28 November 2012, 09:22

Disqus is a great service! Without any doubt - brilliant comments system for any website you have. With it you no longer need to care about implementing comments system, moderation tools, social stream etc. Everything you need from commenting system is there. However there is one problem with it - it doesn't work with real XHTML applications (not so common over the net, but still). What's even worse Disqus team stated clearly that they will not care about XHTML applications. If they won't, then I will :).

Tags: , , , ,

» Komentarze

Luźne i długie notatki o załatwianiu pożyczek i/lub kredytów hipitecznych

Tuesday, 31 July 2012, 11:22

Tym razem nie będzie technicznie. Nie będzie w sumie w ogóle zawodowo. Po prostu nie mogę sobie odpuścić spisania tych przygód. Tak się stało, że przez ostatnie pół roku miałem całe mnóstwo zawirowań związanych z nieruchomościami, kredytami, a najczęściej jednym i drugim na raz. Nie chodzi mi broń boże o jakieś wylewanie gorzkich żali - jak się chce coś w życiu mieć, to nieraz trzeba pozasuwać. Ale niektóre aspekty, z którymi musiałem się stykać są tak absurdalne, że nawet jeśli to nie dotrze do kogokolwiek, kto w którejkolwiek instytucji mógłby cokolwiek zmienić, to może chociaż ktoś się w niemocy uśmiechnie, albo odetchnie z ulgą, jakie to ma jednak lekkie życie. Zetknąłem się z różnymi instytucjami - od banków, przez doradców i pośredników kredytowych, po urzędy samorządów lokalnych, do tego PKP i kilka innych instytucji. Smutne jest jedynie to, że na co dzień mam styczność z tego typu absurdami na każdym kroku (jak zapewne większość z Was) w większości instytucji i po prostu tym razem natężenie absurdów przerosło poziom, który można by określić mianem barejowskiego.

Tags: , , ,

» Komentarze

JavaScript Zend-like url helper

Monday, 25 July 2011, 20:35

In JavaScript, especially when you work with AJAX (many requests to frontend host) and dynamic UI (many requests for assets like images) you have to resolve a lot of URLs. Problem comes, when you have to keep some base of your URLs reference (like web application base URL), or keep your links switchable easily (static hosts balancing). If you are familiar with Zend_Framework, you must know baseUrl() helper for Zend_View. Isn't that a handful thing? Then why not use it in your client scripts as well :)? Here I propose my solution for easy URLs resolving that behaves much like Zend_View's baseUrl() helper.

Tags: , ,

» Komentarze