Displaying only certain aticles

Displaying only certain aticles

Postby Mischa on Fri Jun 24, 2011 5:51 am

Lifetype is so nice.
Customizing it with the plugin Getcategory is very nice, too.

Fist question, for general understanding, about API, i guess:
- How are articles from categories with "don't show on first page" excluded from showing up on mainpage?
I don't see a mechanism for that in the main. or post.templates (like a switch, tag, or such, and no if-statements...)

Secondly, what I am trying to accomplish:
- One category, not show up in the panel list (which now displays all categories)
- That category, should get its own page/template, and on that static page, all the articles from that category gets posted, with dates, ability to comment and all.
(I have done this with Getcategory plugin, but no dates etc show up)

Info:
- Site: http://www.xn--skyddamiljn-0fb.nu/
- Static pages in question:

Happy mid-summer to all! (Personally, I don't, but it is celebrated a lot in our Nordic countries...)
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: Displaying only certain aticles

Postby raciloni on Sun Jun 26, 2011 9:52 am

Articles from categories with "don't show on first page" are not excluded in templates but in lifetype core when it gets the articles from the databsae.

To display date and add the ability to comment articles, replace :
Code: Select all
{if $getcategory}
  {assign var="pressarticles"
          value=$getcategory->getArticles("stymer", 0)}
  {foreach from=$pressarticles item=pa}
    {assign var="postTitle" value=$pa->getTopic()}
    {assign var="permLink" value=$url->postPermalink($pa)}
      <h3 class="storytitle">{$pa->getTopic()}</h3>
       {$pa->getText()}
  {/foreach}
{/if}


with

Code: Select all
{if $getcategory}
  {assign var="pressarticles"
          value=$getcategory->getArticles("stymer", 0)}
  {foreach from=$pressarticles item=pa}
    {assign var="postTitle" value=$pa->getTopic()}
    {assign var="permLink" value=$url->postPermalink($pa)}
   {assign var="postDate" value=$pa->getDateObject()}

      <h3 class="storytitle"><a href="{$url->postPermalink($pa)}" rel="bookmark">{$pa->getTopic()}</a></h3>
      <h4>{$locale->formatDate($postDate,"%d %B  %Y")}</h4>
      
       {$pa->getText()|strip_tags|truncate:1400:"...":false}

<a href="{$url->postPermalink($pa)}" rel="bookmark">[more]</a>
  {/foreach}
{/if}



To display all categories except one category

Code: Select all
   {foreach from=$articlecategories item=articleCategory}
      {if  $articleCategory->getId() != 28}
       <li><a title="{$articleCategory->getName()}" href="{$url->categoryLink($articleCategory)}">{$articleCategory->getName()}</a></li>
      {/if}
         {/foreach}
raciloni
 
Posts: 7
Joined: Sun Dec 13, 2009 3:22 pm
LifeType Version: lifetype-1.2.11_r711

Re: Displaying only certain aticles

Postby Mischa on Sun Jun 26, 2011 4:15 pm

Thank you very much, raciloni!
Worked very well!

I excluded more categories from my panel with this:
Code: Select all
{if $articleCategory->getId() !=28 && $articleCategory->getId() !=12 && $articleCategory->getId() !=8 && $articleCategory->getId() !=11 && $articleCategory->getId() !=17}

Is that the correct way, or is there a shorter method?
(Like "if article category is not 28 OR not 12"?)
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


Return to Templates

cron