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!

[Symfony 2][Assetic] Sass, CompassFilter + Foundation Responsive Front-end Framework

Did you ever wonder how to enable 3rd party plugins (or so called “frameworks“) within the great compass toolset managed by assetic in your edgy symfony 2.1 project?

(If there is more extensive documentation available concerning assetic + CompassFilter, please stop reading on and let me know!)

If you take a look at the filter class itself (it is CompassFilter in the generic Assetic\Filter namespace), you should recognise several option values that you can use in your application wide config.yml file.

But first you have to install the framework plugin following these instructions.

Continue reading “[Symfony 2][Assetic] Sass, CompassFilter + Foundation Responsive Front-end Framework”

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”

Check if a country is an EU country in Magento

I you ever wondered how you can check if a Country, resp. a Country Code, is in the EU, i did the following:

Magento has a config value: eu_countries that lists all Countries of the EU.

You can find it in the backend under:
Configuration -> General -> Country Options.

Against this list you can validate your country code, f.e. that you got in an billing or shipping address of an order.

Continue reading “Check if a country is an EU country in Magento”

Caching Data in Symfony2

Symfony2 has a great Caching Layer based on its HTTP Cache. But this aims mainly on caching the views.

In some apps however you need to cache data behind the scenes, f.e. responses from API calls or custom objects sets.
Symfony2 itself doesnt have such a functionality on first sight (symfony2 doesnt, but Doctrine, see below) and so I searched for one and first found a bundle which utilize the Zend Cache lib:
https://github.com/KnpLabs/KnpZendCacheBundle

This worked well but as discussed here(https://github.com/KnpLabs/KnpZendCacheBundle/issues/2) this adds dependencies to your Symfony2 project. This is actually not necessary since Doctrine/Commons is almost always part of your Symfony2 distribution and the Doctrine/Commons provides a Cache Layer as well.
A very good one, indeed.

So if you need to cache data use Doctrine/Commons.
Continue reading “Caching Data in Symfony2”

Opengraph MetaTags in SilverStripe

First off some general thoughts on how to use opengraph metatags.
Since the uprise of Social Media, sharing sites, deeplinking and snippetting content has become a important aspect of SEO and so almost every site has some kind of facebook-like-button to let user easily share the page.
Most sharing endpoints, facebook f.e, bring a more or less good parser/linter to summarize the page content. So the first text paragraph will be taken as text snippet and all images that fit certain requirements will be offered to chose a preview-thumbnail from.
So far so good.
Continue reading “Opengraph MetaTags in SilverStripe”