view-helpers

What is the best practice to create a custom helper function in php Laravel 5?

狂风中的少年 提交于 2019-11-27 12:59:07
问题 I have the default created_at date keep printing out as an MySQL format : 2015-06-12 09:01:26. I wanted to print it as my own way like 12/2/2017 , and other formats in the future. I created a file called DataHelper.php and store it at /app/Helpers/DateHelper.php - and it looks like this <?php namespace App\Helpers; class DateHelper { public static function dateFormat1($date) { if ($date) { $dt = new DateTime($date); return $dt->format("m/d/y"); // 10/27/2014 } } } I want to be able to called

Rails 3.1: Better way to expose an engine's helper within the client app

自闭症网瘾萝莉.ら 提交于 2019-11-27 04:22:05
问题 I have found a few articles addressing the issue of helpers within an engine not being accessible to the consuming (parent) application. To make sure we are all on the same page, let's say we have this: module MyEngine module ImportantHelper def some_important_helper ...do something important... end end end If you look at the rails engine documentation in the "Isolated engine's helpers" (L293), it says: # Sometimes you may want to isolate engine, but use helpers that are defined for it. # If

Rails 3 View helper method in Model

假如想象 提交于 2019-11-27 02:51:30
问题 I have a class method in my model, and I need to access a method from one of my view helpers. Currently I am including include TalkHelper , but I still get a NoMethodError. 回答1: You may place helper in your lib folder and include them anythere. Like this: lib/some_helper.rb module SomeHelper def somedef #your code there end end 回答2: In your model, you can do something like the following: ApplicationController.helpers.your_helper_method OR YourController.helpers.your_helper_method The best

How to add a view helper directory (zend framework)

走远了吗. 提交于 2019-11-26 18:28:02
问题 I begin with ZF (1.9.7), and I want to use View Helpers from a library shared between all my projects. But I can't find how to add it directory to the helpers path. My herpers works fines when I put them in application's helpers path. Here is the error, where I find the path to ZF helpers, and path to the applications ones. object(ArrayObject)#71 (3) { ["exception"]=> object(Zend_Loader_PluginLoader_Exception)#70 (6) { ["message:protected"]=> string(151) "Plugin by name 'Voo' was not found in