Symfony and named ParamConverters

Symfony’s ParamConverter is a common way to transform some GET param to an entity before your controllers action.
This happens most of the time via type hinting and priority detection kinda magic in the background.
But as magic is often obscure sometimes you need a bit of explicitness.

F.e. when you have more and different ParamConverter per entity you want to name them explicitly.
Then you can use named ParamConverters.

In the documentation this issue is a bit fragmented, so here is the compact version:
Continue reading “Symfony and named ParamConverters”

Enable Twig-Extensions in Silex revisited

As of 2014 things have changed improved a lot in the Symfony / Silex world, compared to 2011, when i first blogged about twig extensions in Silex.
Things got more easy, yay!

As Composer appeared, installation and autoloading is a breeze nowadays.
I presume here, that you have installed your Silex project via composer.
If so, you can install the twig extensions like this:
Continue reading “Enable Twig-Extensions in Silex revisited”

SilverStripe LinkField addon

Alright folks, so here is the SilverStripe addon of the month:
https://github.com/sheadawson/silverstripe-linkable

Its the missing LinkField, you might look for.
There are some more addons for a LinkField out there, but this one is the best.
No wonder, the author is SilverStripe employee.

It features:

  • external links
  • link validation
  • link a page from your site
  • link a file from your assets
  • oEmbed links
  • the addon is translated, currently only for german, but add your own, its easy!

Continue reading “SilverStripe LinkField addon”

Rename admin menu items in SilverStripe

SilverStripe 3.0.x cheap trick of the week:

If you want to rename a menu item in the SilverStripe Admin Area, because f.e. you find “Security” or “Sicherheit”(since we are german ;)) a too harsh wording and you prefer “Members” or “Benutzer”:
simply override the translation!

Add a lang folder in your project folder and add the language file:
de.yml or en.yml and place your wording:

de:
  SecurityAdmin:
    MENUTITLE: Benutzer

Continue reading “Rename admin menu items in SilverStripe”

SilverStripe speed up Portfolio Sites with Static Publisher

A common site type that we build are portfolio pages
which mostly get filled once in the beginning and then only periodically, rather rarely.
They also have almost never User interaction from the Frontend.

So we consider them as almost “readonly” sites.

These sites you can easily speed up “dramatically” with the SilverStripe builtin StaticPublisher.
The tweaks you need for this are moderate to easy.

You can read the Docs to get a glimpse of what is possible.
I will just describe the basic setup to make a site static.
Continue reading “SilverStripe speed up Portfolio Sites with Static Publisher”

Silverstripe remove CustomScript

Silverstripe Tip of the week:

Sometimes you have to remove a customScript of a module, because you want to script it differently.

If the module author was so wise to give his customScript a ID (UserFormsValidation in this case) like they did in UserForms:

Requirements::customScript(<<<JS
    (function($) {...})(jQuery);
JS
, 'UserFormsValidation');

then you can do the following in the init function of your subclass controller:

Requirements::block('UserFormsValidation');

Easy, isnt it?

Silverstripe RedirectorPage open external Link in new window

Silverstripe Tip of the Week:

If you want to open a “Other website URL” Link of a RedirectorPage in a new window with target=_blank, you can use the following snippet:

<% if ExternalURL %>
   <a href="$ExternalURL" class="external" target="_blank">$MenuTitle.XML</a>
<% else %>
   <a href="$Link">$MenuTitle.XML</a>
<% end_if %>

Edit:
Or this one:

<% if is_a(RedirectorPage) %><% if RedirectionType = External %>target="_blank"<% end_if %><% end_if %>

found here: http://www.silverstripe.org/general-questions/show/9600

Hope it Helps!

Symfony2 from YAML to XML configuration

Actually i was a fan of YAML regarding the configuration files of Symfony2.
This was probably because i was used to it since symfony 1.4 and i also thought its better readable.
Its partly still true, but my Netbeans Editor has some problems with using @ in YAML and this breaks my highlighting.
So the better readability vanished to nirvana.

So i checked out XML configuration. Its also widely used by the community.
Pros and Cons (mostly Pros) you can read in this post by Fabien.

Continue reading “Symfony2 from YAML to XML configuration”