Results 1 to 2 of 2

Thread: Adjust ModuleNews to the PHP 5.3 style (Using $this when not in object context)

  1. #1
    User tetrijeb's Avatar
    Join Date
    04-19-12.
    Location
    Bosnia&Herzegovina
    Posts
    114

    Default Adjust ModuleNews to the PHP 5.3 style (Using $this when not in object context)

    Hello,

    I upgraded my website from the 2.11 to 3.5 (news archive copied from the old database) and now wherever I have news item in news archive, where there is some text besides news-teaser I am getting error

    Using $this when not in object context in /var/www/vhosts/***/httpdocs/system/modules/news/modules/ModuleNews.php on line 144
    Well, I find this kind of topic regarding Listing module, where it was solved to support backward compatibility.

    https://github.com/contao/core/commi...41501bcf937418

    Is it possible to do something similar with NewsModule.php? On line 144 there is:

    PHP Code:
    // Compile the news text
            
    else
            {
                
    $id $objArticle->id;

                
    $objTemplate->text = function () use ($id)
                {
                    
    $strText '';
                    
    $objElement = \ContentModel::findPublishedByPidAndTable($id'tl_news');

                    if (
    $objElement !== null)
                    {
                        while (
    $objElement->next())
                        {
                            
    $strText .= $this->getContentElement($objElement->current());

                        }
                    }

                    return 
    $strText;
                };

                
    $objTemplate->hasText = (\ContentModel::countPublishedByPidAndTable($objArticle->id'tl_news') > 0);
            } 
    I understand it has something with static and non-static functions, but it is far beyond my PHP knowledge.

    Regards
    Last edited by tetrijeb; 11/28/2015 at 02:28.

  2. #2
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    You should (can) not copy DB-tables between different Contao versions.

    If you do a regular update your news from 2.11 should be ok in 3.5.

    And you need at least PHP 5.4 to run Contao 3.5.
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •