helper

distance_of_time_in_words gone crazy!

distance_of_time_in_words(strtotime(2010-08-07), strtotime(2010-08-01)) returns '6 minutes' $a = '2010-08-02 00:39:29' $b = '2010-08-01' distance_of_time_in_words($a, $b) returns 'less than a minute' $a = '2010-08-02 00:39:29' $b = '2010-08-01 20:08:00' distance_of_time_in_words($a, $b) returns 'less than a minute' I wonder if I...

how to call multiple controller action from within any action in zend framework?

hi all, i have a controller action and i want it to be execute after any action. i have written an action helper with this method: public function postDispatch() { $actionstack = Zend_Controller_Action_HelperBroker::getStaticHelper('actionStack'); $actionstack->direct('myaction', 'mycontroller'); } but it seems that it stuc...

rails view helper each with separator

I'm sure I saw a while back a rails helper method where .each in the view accepts a separator such as a comma. So say I want: - @results.each do |result| = result.title #to output result 1, result 2, result 3 TIA ...

Why use CakePhp AJAX helper instead of jQuery?

Hello, I'm just starting using cakePHP and I saw on that there was an AJAX Helper in it. My question is simple : should I rather use this helper or should I keep doing AJAX with jQuery? Are there any changes I should perform in existing jQuery AJAX calls? Thanks ...

How can I make this code (helper) DRY in Rails where I am calling similar Models?

The end goal is to create a helper found at the end called show_status(contact,event). Event can be any object, Email, Letter, etcetera. The combination of an Email template sent to a Contact is a specific record ContactEmail. Because each event has a different corresponding Model I need to do the .find on, I have duplication. There ...

Testing view helpers in Rails with RSpec

Guys, I need to test the following helper: def display_all_courses @courses = Course.all output = "" for course in @courses do output << content_tag(:li, :id => course.title.gsub(" ", "-").downcase.strip) do concat content_tag(:h1, course.title) concat link_to("Edit", edit_course_path(course)) end end ...

codeigniter use of redirect()

I use redirect() (from uri helper) in every function who need to load the main view of my app. It redirect to the same function. My goal is to get the same clean uri, even when i use a pages' feature (that call other controller). Is it good practice? When should i use redirect()? Are there any other solution to get a similar result? th...

Converting Rails 3 to Rails 2: helpers with blocks

In Rails 3 I use the following helper in order to get a even-odd-coloured table: def bicolor_table(collection, classes = [], &block) string = "" even = 0 for item in collection string << content_tag(:tr, :class => (((even % 2 == 0) ? "even " : "odd ") + classes.join(" "))) do yield(item) end even = 1 - even e...

Rails show X image if Case reference is M10-XXX?

Hi Everyone, I currently have a model that the user can upload a thumbnail to the record which is then shown on the show view page. This thumbnail was originally intended so the user could easily find the case when searching through the index view table of records. It has become apparent that users are only using this function to uplo...

Existing script to loop through date range by day, week, month, year?

I'm trying to find an existing helper function that will accept a start and end date and interval (day, week, month, year), and will return an array each day, week month or year in that range. Would love to find a pre-existing one if it's out there. Thanks! ...

What's Yii's equivalent for other MVC's Libraries and Helpers?

What's Yii's way of implementing modular functionality to use from Controllers, as there are Helpers and Libraries on Kohana and CodeIgniter? ...

Extract to Rails helper

I want to make this thing more generic. <%= form_for :page, :url => { :action => :create } do |form| %> <div class="tabs"> <ul> <% languages.each_with_index do |lang, i| %> <li><a href="#tabs-<%= i+1 %>"><%= lang %></a></li> <% end %> </ul> <% languages.each_with_index do |lang, i| %> <div id="tabs-<%= i+1 %>"> <field...

Stackoverflow like pagination helper in asp.net mvc

Is there any pagination helper like stackoverflow in asp.net mvc? ...

Form helper not auto-filling a belongsTo select box in cakephp

This is causing me a bit of frustration this morning/late last night, and I'm sure I must be missing something painfully simple here.... In my view I have: echo $this->Form->input('form_generator_field_type_id'); and in my controller I have: $form_generator_field_types=$this->FormField->FormFieldType->find('list'); $this->set('form_...

What is a more elegant solution to these nested if/elseif statements?

I'm building a website that contains users with user profiles. Many of the fields in the profile are optional. There is an opportunity for a lot of user-generated content, and so I need to display the author of this content in many different locations of the site (comments, posts, etc.). In the user's profile, he is able to (optiona...

Rails: Would this go in a helper?

I've currently got this in my view file: <%= "<em>(#{package.to_company})</em>" unless package.to_company.blank? %> Is my understanding correct that I should move that to a helper? ie. def package_company(package) "<em>(#{package.to_company})</em>" unless package.to_company.blank? end I ask because I've got a few dozen unless st...

Model Helper Zend

from what i know there is only action helper & view helper available at zend framework. is there any model helper? or how we can implement the model helper? ...

CakePHP form helper problem with date for editing

I'm quite newbie in CakePHP, I've tried to create a form with form helper on a date field echo $this->Form->input('Item.date'); yes, works fine (I'm using CakePHP v1.3.3) for input/add new record but when I try using it on edit page it does nothing. here's the code echo $this->Form->input('Item.date', array("value"=>$rs['Item']['date...

CakePHP: Strip HTML using Text helper?

Hi, I'm using the truncate method of the text helper and in doing so means any html included in the text is being rendered. Is there anyway to set the text helper to strip out html tags? echo $text->truncate( $project['Project']['description'], 250, array( ...

How to use Js->submit() in CakePHP?

Im trying to create a simple Ajax form for a message board in a CakePHP application, but I can't for the life of me figure out how to properly use the Js->submit() function to submit a form via Ajax. Heres the form code within my view: <?php echo $this->Form->create('Message',array( 'type' => 'post', 'action' => 'add', 'onSubm...