Expression Engine

ExpressionEngine Category for Entry

I wanted to display the category of an entry so that the end result would look like the following, where Ruby on Rails is the category:

RUBY ON RAILS
Scaling ActiveRecord
Thursday September 25, 2008 at 10:26pm

I couldn’t find any examples, but the snippets in TextMate helped me out.  Here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{exp:weblog:entries weblog="posts"}
  <div class="post">
    <h3>
      {categories weblog="posts"}
      {category_name}
      {/categories}      
    </h3>
    <h2>
      <a href="{title_permalink="posts/view"}">
        {title}
      </a>
    </h2>
    <div class="post-date">
      {gmt_entry_date format="%l %F %d, %Y at %g:%i%a"}
    </div>
  </div>      
{/exp:weblog:entries}

Reader Discussion

Kenan

Monday November 30, 2009 at 12:49pm

Hi,
Great plugin but I’m having trouble.
When post is just published sometimes its before 2 minutes, sometimes before 1 hour, sometimes before 0 years… every time is different time?
After few hours its OK.

Do You know what could causing this?

Thanks

Comment on this post




Please enter the word you see in the image below:


Related posts

Blank Screen with Expression Engine

I am going to use this post to track the occasions when I get inexplicable blank screens in Expression Engine.

Issue #1 - Relative Date plugin syntax error

Symptoms: After adding the first entry to a weblog I would get a blank screen. If I changed the status of the entry to Closed, the page would be ok. If I opened it again it would be blank. No debug messages would show.

Resolution: My templates rely on the relative_dates plugin. The syntax of the plugin was incorrect. Line one of the file was <? but should have been <?php. This thread on the Expression Engine forum got me jump started on resolving the issue.

read more

Using /home/* on a mac

I want the path on my Mac dev environment to match the path on my Linux server (I am doing this for ExpressionEngine, where it’s much easier to deploy to different servers if the paths match).

My Linux server path starts with /home/myusername. Unfortunately, in Mac Leopard the /home directory is not editable, so I cannot put my files in the directory I need.

I found a solution buried in an Apple support forum message. The solution is to comment out an entry in the the auto_master file.

Here are the steps:

  1. edit the file: /etc/auto_master
  2. comment out this line: # /home auto_home -nobrowse
  3. save & reboot

After reboot the /home directory acted like I expected and now I have my ExpressionEngine files where I need them.

read more

Relative time formatting with ExpressionEngine

I started using David Rencher’s handy Relative Date plugin for ExpressionEngine.

Here is an example output:

About 1 week, 2 days, 21 hours, 13 minutes ago

The formatting comes from a php function called Localize::format_timespan. It would be great for doing a count down timer to some event, but it is not so great for displaying the age of a blog post.

I was looking for a formatting method in PHP that behaves like the time_ago_in_words method in Rails. I found it here: http://snippets.dzone.com/posts/show/5658. Sweet.

So, I modified the original relative_date plugin to use the new method.

Here is the new output:

About 10 days ago

You can download the new file here: pi.relative_date_.php_.zip.

read more