X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   News posts on home page (https://forum.x-cart.com/showthread.php?t=48437)

ARW VISIONS 07-03-2009 11:25 AM

News posts on home page
 
How can I ahve more than one news post on the home page? Like maybe all active?

ARW VISIONS 07-05-2009 07:22 PM

Re: News posts on home page
 
anyone?

Victor D 07-14-2009 02:27 PM

Re: News posts on home page
 
add in the end of modules/News_Management/func.php
Code:

function insert_news_get_num($lngcode) { return array_slice(func_news_get($lngcode), 0, 3);}



then in skin1/customer/news.tpl change
Code:

{if $is_news_exist}

    {capture name=menu}

      <div class="news item">
        {include file="today_news.tpl"}
      </div>


to

Code:

{if $is_news_exist}

    {capture name=menu}

    {if $news_message eq ""}
      <div class="news item">{$lng.txt_no_news_available}</div>
    {else}

      {insert name="gate" func="news_get_num" assign="all_news"  lngcode=$shop_language}
      {section name=newsloop loop=$all_news}
        <div class="news item">
          <strong>          {$all_news[newsloop].date|date_format:$config.Appearance.date_format}</strong><br />
  {$all_news[newsloop].body}<br />
      </div>
        {/section}
        <br />
      {if $usertype eq "C"}
        <a href="news.php" class="small-link prev-news">{$lng.lbl_previous_news}</a>
        {/if}
      {/if}


This should work, though I didn't tested it.

matallen 09-10-2009 07:14 AM

Re: News posts on home page
 
I just tried this and am getting this error:

Quote:

Warning: array_slice() expects parameter 1 to be array, boolean given in /modules/News_Management/func.php on line 82

I'd really appreciate your help as this is EXACTLY what I need to do! Thanks so much!

Victor D 09-11-2009 06:45 AM

Re: News posts on home page
 
Quote:

Originally Posted by matallen
Warning: array_slice() expects parameter 1 to be array, boolean given in /modules/News_Management/func.php on line 82


You have no news for the current language I suppose.

try to replace
Code:

function insert_news_get_num($lngcode) { return array_slice(func_news_get($lngcode), 0, 3);}
with
Code:

function insert_news_get_num($lngcode) {$news = func_news_get($lngcode);
 return $news ? array_slice($news, 0, 3) : false;}


matallen 09-11-2009 06:50 AM

Re: News posts on home page
 
Okay I did that - That got rid of the error but now there are no news items showing. If I click the "Previous News" link it takes me to the news page where I have two items showing. What classifies as "Current News"?? Thanks SOOO much for your help!

matallen 09-11-2009 07:01 AM

Re: News posts on home page
 
Also - I went and looked at the news system and saw where it said I could pick a language. Well there is nothing there for language. I have english set as the default/only language in my cart. I tried enabling Spanish and a drop down appeared across from the language label on the news management screen. It was grayed out and said English. This did not fix the issue however.

Victor D 09-11-2009 07:06 AM

Re: News posts on home page
 
Thank you, it should be
Code:

function insert_news_get_num($conf) {$news = func_news_get($conf['lngcode']);
 return $news ? array_slice($news, 0, 3) : false;}

as the language code was taken incorrectly.

matallen 09-11-2009 11:16 AM

Re: News posts on home page
 
You are amazing! :D/ Thanks so much! Hopefully I'm not bothering you too much but can you point me in the right direction if I only want to show the Message "Subject" or if I'd want to only display the first x number of words the message? :lol:

Victor D 09-15-2009 02:00 AM

Re: News posts on home page
 
Code:

{if $is_news_exist}
    {capture name=menu}
    {if $news_message eq ""}
      <div class="news item">{$lng.txt_no_news_available}</div>
    {else}
      {insert name="gate" func="news_get_num" assign="all_news"  lngcode=$shop_language}
      {section name=newsloop loop=$all_news}
        <div class="news item">
        <strong>          {$all_news[newsloop].date|date_format:$config.Appearance.date_format}</strong><br />
  {$all_news[newsloop].body}<br />
        </div>
      {/section}
      <br />
      {if $usertype eq "C"}
        <a href="news.php" class="small-link prev-news">{$lng.lbl_previous_news}</a>
      {/if}
{/if}

->
Code:

{if $is_news_exist}
    {capture name=menu}
    {if $news_message eq ""}
      <div class="news item">{$lng.txt_no_news_available}</div>
    {else}
      {insert name="gate" func="news_get_num" assign="all_news"  lngcode=$shop_language}
      {section name=newsloop loop=$all_news}
        <div class="news item">
        <strong>          {$all_news[newsloop].date|date_format:$config.Appearance.date_format}</strong><br />
  {$all_news[newsloop].body|truncate:200}<br />
        </div>
      {/section}
      <br />
      {if $usertype eq "C"}
        <a href="news.php" class="small-link prev-news">{$lng.lbl_previous_news}</a>
      {/if}
{/if}



All times are GMT -8. The time now is 08:15 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.