Showing posts with label helper. Show all posts
Showing posts with label helper. Show all posts

2016/11/20

Fatal Error in Magento: Class Mage_YourModule_Helper_Data not found in app/Mage.php on line 547

This is an error, which I faced some times after late nights in code.

It is a very bad error message, because it does not explain what´s really going wrong. This is also problem, because you do not know where to search for the error. Especially if you done some more changes in your code and you need to go through every single change with your GIT diff.

The reason of this error is, that you or another module of your Magento installations accesses a configuration from the XML files which is not valid. In most cases it is a typing error in a recent added or changed config section.

The solution


To solve this error: go carefully through your XML configuration in config.xml, adminhtml.xml, system.xml or any layout XML file and find the mistyping node.
It could be a close-Tag which is typed different from the open-Tag or vise versa. Or it could be a missing close-Tag.

Sometimes some of this mistakes could also lead to strange behaviour like your custom module is not activated anymore and as a result controllers actions are not working which will cause 404 on routes that were working before this mistakes.

I hope this little hint will save somebody ours of debugging!

2012/01/17

Einbinden von Styles und Scripts


Nach der vierten Auflage von "Agile Web Development with Rails" - und damit vermutlich nach den Konventionen von Rails < 3.1 - gehören Stylesheets und Javascripts in den /public/stylesheets Ordner und wird mit folgendem Methodenaufruf in das Layout geladen:
<%= stylesheet_link_tag "application" %>

Der String-Parameter "application" gibt an, welche CSS geladen wird.
Leider verlinkt der ausgegebene Link-Tag nicht auf den Ordner /public sondern /assets
Nach einer schnellen Suche im Ruby on Rails Guide ist eine Funktion namens Asset Pipeline per default eingeschaltet: http://guides.rubyonrails.org/asset_pipeline.html
Diese Funktion erlaubt es, Javascript und CSS zu bündeln und zu komprimieren um die Applikation zu optimieren.
Ebenso interessant dieser Funktion ist in Kapitel 2 des obigen Links nachzulesen: Es ermöglicht dem Entwickler, beispielsweise CSS nur dann zu laden, wenn es auch wirklich gebraucht wird. Dies wird über Controller definiert.
Der Scaffold-Befehl wird automatisch für jeden Controller in /assets/stylesheets/ eine CSS Datei erstellen.
Wenn man aber nun statt application.css eine andere CSS-Datei einbinden möchte, trifft man auf folgenden Fehler: 
Sprockets::CircularDependencyError in Controllername::Actionname

Um diesen Fehler zu umgehen, muss man die application.css löschen.
Damit immer nur das nötigste geladen wird lässt sich nun mit
<%= stylesheet_link_tag params[:controller] %>

die jeweilige CSS zum aufgerufenen Controller laden. Diese werden, wie schon erwähnt, mit jedem Scaffold automatisch erstellt und mit dem Suffix .css.scss in /assets/stylesheets/ abgelegt. 
Auf anhieb hat dies bei mir nicht funktioniert, aber nach einem Neustart des Servers wurden dann nur die nötigen CSS-Dateien geladen.