Find article by ID

3 views
Skip to first unread message

Andrei Maxim

unread,
Apr 26, 2007, 12:00:25 PM4/26/07
to Liquid Templates
Hi folks,

I'm trying to build some sort of custom CMS for a small project I'm
doing. I'm not really fond of all those menus so I'm trying to use
Liquid to do all the design and templating.

I want to be able to assign a specific article based on the ID, some
like:

{{ assign main_article = articles.find[123] }}

where 123 is the ID of an article.

How should I do this?

Thanks,

Andrei

Lance Carlson

unread,
Apr 26, 2007, 1:47:43 PM4/26/07
to liquid-t...@googlegroups.com
Andrei,

You should grab the article information inside of the controller before you push to the liquid template.

article_controller:

def show
@article =  Article.find(params[:id])
end

so one would visit localhost:3000/article/show/1 and the article would display.

You should also check out Mephisto Blog. It's a simple CMS that is easy to extend.

-Lance

Andrei Maxim

unread,
Apr 27, 2007, 4:57:56 AM4/27/07
to Liquid Templates
On Apr 26, 8:47 pm, "Lance Carlson" <lancecarl...@gmail.com> wrote:
> You should grab the article information inside of the controller before you
> push to the liquid template.
>
> article_controller:
>
> def show
> @article = Article.find(params[:id])
> end
>
> so one would visit localhost:3000/article/show/1 and the article would
> display.

I'm trying to use Liquid templates to show a certain article. I know
how to fetch the article from the database because it's how I normally
do things now. I'd like to insert a specific article in a predefined
template using Liquid drops/filters, but I don't really understand how
I should do that.

> You should also check out Mephisto Blog. It's a simple CMS that is easy to
> extend.

I use Mephisto for my blog. It's a great tool, although I feel that
some features (like revisions) are a bit too much and that the
database is a bit too complicated (when I'll have the time and the
experience with RoR I'll either submit some patches or fork it), but
it's not _that_ easy to learn from it because of the tight coding.

Reply all
Reply to author
Forward
0 new messages