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...
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...
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
...
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
...
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 ...
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
...
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...
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...
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...
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 way of implementing modular functionality to use from Controllers, as there are Helpers and Libraries on Kohana and CodeIgniter?
...
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...
Is there any pagination helper like stackoverflow in asp.net mvc?
...
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_...
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...
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...
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?
...
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...
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(
...
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...