This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Mathilde Escher Stiftung
Mathilde Escher Stiftung

Hello! Our client likes to have a date displayed in the footer, when they did the last changes to the content of the page.

As the content is saved in the theme I did a component for this, which is getting the stat of the theme in PHP:

public function lastUpdate()
{
    $stat = stat('themes\my-theme');
    return date('d\.m\.Y', $stat['mtime']);
}

This seems to work. But is there a way to get the active theme path, so I don't need to hardcode it?

And, is there a better way to do this?

Mathilde Escher Stiftung
Mathilde Escher Stiftung

UPDATE:

I found it. New code looks now like this:

...
use Cms\Classes\Theme;
...
public function lastUpdate()
{
    $theme = Theme::getActiveTheme();
    $theme_path = $theme->getPath();
    $stat = stat($theme_path);
    return date('d\.m\.Y', $stat['mtime']);
}

Question remains, if this is a proper solution?

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.