Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Add a .desktop suffix to the cache file of a page with a mobile layou…
Browse files Browse the repository at this point in the history
…t (see #7826).
  • Loading branch information
leofeyer committed Jun 3, 2015
1 parent 74515f1 commit 570d80e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Resources/contao/classes/FrontendTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,17 @@ protected function addToCache()
}
}

// Store mobile pages separately
if (\Input::cookie('TL_VIEW') == 'mobile' || (\Environment::get('agent')->mobile && \Input::cookie('TL_VIEW') != 'desktop'))
// Add a suffix if there is a mobile layout (see #7826)
if ($objPage->mobileLayout > 0)
{
$strCacheKey .= '.mobile';
if (\Input::cookie('TL_VIEW') == 'mobile' || (\Environment::get('agent')->mobile && \Input::cookie('TL_VIEW') != 'desktop'))
{
$strCacheKey .= '.mobile';
}
else
{
$strCacheKey .= '.desktop';
}
}

// Replace insert tags for caching
Expand Down
12 changes: 12 additions & 0 deletions src/Resources/contao/controllers/FrontendIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,18 @@ protected function outputFromCache()
}
}

// Check for a desktop layout (see #7826)
if (!$blnFound)
{
$strMd5CacheKey = md5($strCacheKey . '.desktop');
$strCacheFile = TL_ROOT . '/system/cache/html/' . substr($strMd5CacheKey, 0, 1) . '/' . $strMd5CacheKey . '.html';

if (file_exists($strCacheFile))
{
$blnFound = true;
}
}

// Check for a regular layout
if (!$blnFound)
{
Expand Down

0 comments on commit 570d80e

Please sign in to comment.