New template page with articles from one single category

New template page with articles from one single category

Postby Mischa on Thu Sep 09, 2010 9:44 am

Making a new template page, copying post.template.

But I want it to display articles from only ONE category.

My head spinning, but I suppose somebody has already made this, and could tell me how to do it...?
Using lifetype-1.2.12 pretty standard config
Mischa
 
Posts: 39
Joined: Fri Jun 20, 2008 9:27 am
Location: Åland Islands
LifeType Version: 1.2.12

Re: New template page with articles from one single category

Postby jondaley on Thu Sep 09, 2010 3:41 pm

You'll want the getcategory plugin - normal pages only have access to the last 10-15 posts, and you'll probably want the last 10 or so posts in that category, no matter how old they are.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: New template page with articles from one single category

Postby Mischa on Thu Sep 09, 2010 4:37 pm

WOW - superduper ;)

http://www.xn--skyddamiljn-0fb.nu/static/1/help
Brings the one and only article from a category. Thus, I am able to let the menu item "Första hjälpen" to light up ;)

Stripped code in getcategory plugin example contains only one thing i don't understand:
Code: Select all
{if $getcategory}
 <div id="content">
  {assign var="pressarticles"
          value=$getcategory->getArticles("Första Hjälpen", 3)}
  {foreach from=$pressarticles item=pa}

    {assign var="postTitle" value=$pa->getTopic()}
    {assign var="permLink" value=$url->postPermalink($pa)}
       {$pa->getText()}

  {/foreach}
 </div>
{/if}

What is the "3" in this line?:
Code: Select all
          value=$getcategory->getArticles("Första Hjälpen", 3)}
Using lifetype-1.2.12 pretty standard config
Mischa
 
Posts: 39
Joined: Fri Jun 20, 2008 9:27 am
Location: Åland Islands
LifeType Version: 1.2.12

Re: New template page with articles from one single category

Postby jondaley on Sat Sep 11, 2010 3:48 pm

it gets a max of 3 articles from that category.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: New template page with articles from one single category

Postby Mischa on Sun Sep 12, 2010 5:25 am

jondaley wrote:it gets a max of 3 articles from that category.

Duh me!
Nice. And I think a zero gets all articles from that category...
Using lifetype-1.2.12 pretty standard config
Mischa
 
Posts: 39
Joined: Fri Jun 20, 2008 9:27 am
Location: Åland Islands
LifeType Version: 1.2.12

Re: New template page with articles from one single category

Postby jondaley on Sun Sep 12, 2010 8:32 am

-1 is the official way to get all of the articles, but I checked the code, and 0 would work also.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: New template page with articles from one single category

Postby Mischa on Mon Oct 11, 2010 2:46 pm

Superb. I really like this function/plugin.

BUT - i try a simple thing inside the getcategory code, namely to attach the article date above the text of the article.
No matter what I do (noob as I am to LifeType API...), the result is blank page, no articles are gotten.

Somewhere i want to add something like:
Code: Select all
$article->setDateObject($article->getDateObject());
And then display it in a line above the article text.

But how?
Using lifetype-1.2.12 pretty standard config
Mischa
 
Posts: 39
Joined: Fri Jun 20, 2008 9:27 am
Location: Åland Islands
LifeType Version: 1.2.12

Re: New template page with articles from one single category

Postby jondaley on Tue Oct 12, 2010 5:41 pm

What are you trying to do? If you are calling ...set(...get()) that doesn't really make any sense, since if you can call get on it, that means you don't need to call set, since the data is already there...
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: New template page with articles from one single category

Postby Mischa on Tue Oct 12, 2010 6:15 pm

I only want to:
"attach the article date above the text of the article", the article gathered by the getcategory plugin...
Using lifetype-1.2.12 pretty standard config
Mischa
 
Posts: 39
Joined: Fri Jun 20, 2008 9:27 am
Location: Åland Islands
LifeType Version: 1.2.12

Re: New template page with articles from one single category

Postby jondaley on Thu Oct 14, 2010 10:42 am

The date should already be set on the object returned by the getcategory plugin, so you should be able to simply call:
$date = $article->getDate() which will return a number, that you can pass into php's date() function, or you can use $timestamp = $article->getDateObject() which will return a (LifeType) Timestamp object that you can call $timestamp->getMInutes() etc to get the parts you want.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch


Return to Templates

cron