Support » Plugin: Timber » Issue in Routers.php file after updating to 6.0 WP version and Timber Plugin

  • There is an issue in Routers.php file after updating to 6.0 WP version and Timber Plugin.

    Using the “\Routes::map()” and “\Routes::load” function in routers.php.

    But not getting post’s data in the “account_controller”, tried using “\Timber::query_post()” and “new \Timber\Post()” functions to fetch post’s data but both of them are not working.

    Can you please help me to solve this issue?

    Routers.php code:

    \Routes::map('/profile',function($params){
                $query = sprintf('posts_per_page=1&post_status=publish&post_type=%s&name=%s','page','profile');
                $params['action'] = 'viewUserProfileAction';
                $params['controller'] = 'account_controller';
               \Routes::load(self::HANDLER, $params, $query, 200); 
            });

    account_controller.php code:
    $p = \Timber::query_post(); //new \Timber\Post();

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter rakesh1247

    (@rakesh1247)

    Added tags

    • This reply was modified 3 months, 2 weeks ago by rakesh1247.
    Plugin Author jarednova

    (@jarednova)

    This is now resolved in Timber 1.20.0 — thanks @rakesh1247 !

    Thread Starter rakesh1247

    (@rakesh1247)

    @jarednova I have updated the Timber plugin to 1.20.0 version and WordPress version to 6.0 but still it is not working like it was before WordPress and Timber plugin update.

    Now the control is not coming to routers.php file which we use to make custom routes.

    \Routes::map('/profile',function($params){
                $query = sprintf('posts_per_page=1&post_status=publish&post_type=%s&name=%s','page','profile');
                $params['action'] = 'viewUserProfileAction';
                $params['controller'] = 'account_controller';
               \Routes::load(self::HANDLER, $params, $query, 200); 
            });

    Now it is displaying wordpress default pages like for single page it is displaying the single.php file not the custom file which is written in routers.php file.

    Do you now the exact reason behind this issue?

    Thread Starter rakesh1247

    (@rakesh1247)

    Hi @jarednova I have found the issue in \Routes::map() function.
    Actually before we were passing multiple routes together by using implode function we made a string of routes to pass as first argument in \Routes::map() function.

    But now it is not working for us, so can you please tell us if we have to do change in our code or logic?

    //string of routes
    $pattern = ‘(‘ . implode(‘|’, self::$url_mappings[‘Collection’]) . ‘)’;
    // output of $pattern variable is like “(evergreen-trees|house-plants/ferns|redbud-trees|holly-trees)”.

    \Routes::map($pattern,function($params){
    // added code here
    });

    • This reply was modified 2 months, 3 weeks ago by rakesh1247.
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.