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)
-   -   Showing more than 1 News story on the Home page (https://forum.x-cart.com/showthread.php?t=57642)

rhu 01-20-2011 11:55 AM

Showing more than 1 News story on the Home page
 
I'm trying to show 5 news message on the home page, but I noticed from the debugging tool that the $news_message only has one story in the array.

In news.php however, there's a new variable called $news_messages which has multiple stories...

How can I get access to that $news_messages variable from the home page?


I was able to find this thread which talks about exactly what I need, but it doesn't work for 4.4.x

http://forum.x-cart.com/showthread.php?t=48437 - looks like it's only valid for 4.3 and 4.2

chiactivate 11-26-2011 08:09 PM

Re: Showing more than 1 News story on the Home page
 
anybody got solution for this change?

JWait 11-28-2011 08:35 AM

Re: Showing more than 1 News story on the Home page
 
The heart of the display appears to be...

Code:

{insert name="gate" func="news_get_num" assign="all_news"  lngcode=$shop_language}
{section name=newsloop loop=$all_news}
        <div class="newsitem">
          <strong>          {$all_news[newsloop].date|date_format:$config.Appearance.date_format}</strong><br />
  {$all_news[newsloop].body}<br />
      </div>
        {/section}


Try adding that to news.tpl checking first if any of the variables have changed between versions.

chiactivate 11-29-2011 05:07 PM

Re: Showing more than 1 News story on the Home page
 
it didn't work.

By the way, where are these variables stored?

$news_message.date
$all_news

I mean how do you find the right variable and what do they all mean?

Still haven't figured out how this smarty works. Your help is appreciated.

Thanks

JWait 11-30-2011 04:37 AM

Re: Showing more than 1 News story on the Home page
 
I no longer have a copy of 4.0.x to look at, sorry.

chiactivate 12-02-2011 12:45 PM

Re: Showing more than 1 News story on the Home page
 
I'm using 4.44 now

gb2world 12-02-2011 03:50 PM

Re: Showing more than 1 News story on the Home page
 
Use webmaster mode - it shows you the available variables and their contents.

---

JWait 12-03-2011 05:10 AM

Re: Showing more than 1 News story on the Home page
 
Quote:

Originally Posted by chiactivate
I'm using 4.44 now


Have you tried this?
Code:

{*
$Id: news.tpl,v 1.1 2010/05/21 08:31:51 joy Exp $
vim: set ts=2 sw=2 sts=2 et:
*}
{if $active_modules.News_Management}
  {insert name="gate" func="news_exist" assign="is_news_exist" lngcode=$shop_language}

  {if $is_news_exist}

    {insert name="gate" func="news_subscription_allowed" assign="is_subscription_allowed" lngcode=$shop_language}

    <div class="news-box">

      <div class="news">

        <h2>{$lng.lbl_news}</h2>

        {if $news_message eq ""}

          {$lng.txt_no_news_available}

        {else}
      {* Added loop from news_archive.tpl *}
      {foreach from=$news_messages item=m name=news}

        <div{interline name=news additional_class="news-item"}>
          <div class="news-date">{$m.date|date_format:$config.Appearance.date_format}</div>
            <div class="news-title">{$m.subject|amp}</div>
            <div class="news-body">
          {if $m.allow_html eq "N"}
            {$m.body|escape|nl2br}
          {else}
            {$m.body|amp}
          {/if}
        </div>

      </div>

    {/foreach}
    {* Added loop from news_archive.tpl END *}
        {* <strong>{$news_message.date|date_format:$config.Appearance.date_format}</strong><br />
          {$news_message.body} *}
          <br /><br />
          <a href="news.php" class="prev-news">{$lng.lbl_previous_news}</a>
          {if $is_subscription_allowed}
            &nbsp;&nbsp;
            <a href="news.php#subscribe" class="subscribe">{$lng.lbl_subscribe}</a>
          {/if}

        {/if}

      </div>

    </div>

  {/if}
{/if}


I just added the loop from the "light and lucid 2 column" news_archive.tpl and commented out the original call for the one news message. I don't know if it will work or not but probably worth a try.

chiactivate 12-19-2011 06:03 PM

Re: Showing more than 1 News story on the Home page
 
it still didn't work. You are right. Should be copy pasting the loop from news_archive.tpl, but the doesn't work at all.

Added some dummy text inside the loop, but the dummy text didn't show up. So, I guess it didn't even go inside the loop at all.

totaltec 12-19-2011 08:08 PM

Re: Showing more than 1 News story on the Home page
 
This may be obvious, but what we are going to need to do is assign the variable $news_messages somewhere other than news.php.

In modules/News_management/news_manage.php you will see the variable assigned to smarty:
Code:

$smarty->assign('news_messages', func_news_get($shop_language, false, false, "$first_page, $objects_per_page"));

Hope that helps,

-Mike

chiactivate 12-20-2011 05:03 PM

Re: Showing more than 1 News story on the Home page
 
Thanks for your help, but I still don't understand this exactly. I'm not an expert in smarty.

totaltec 12-20-2011 06:28 PM

Re: Showing more than 1 News story on the Home page
 
Chi, you are going to need to do this in php to assign the variable to smarty, then you can access it in your tpl.

Look at news_manage.php, and see how the variable is being assigned to smarty, and the queries that are being used. Then do a recursive search of your X-cart to see where the current news_message variable is being assigned, and then insert your example logic there.

After that is complete you will have passed the variable to smarty, and you can then work with it in templates like you would any other. You are probably going to need a {section} or {foreach} loop to go through your newly assigned array and display each message in the template.

Definitely not for the faint of heart. ;)
I can do this for you if you like, that's what I do.

-Mike

chiactivate 12-22-2011 11:58 AM

Re: Showing more than 1 News story on the Home page
 
thanks. Will give it a try


All times are GMT -8. The time now is 04:44 PM.

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