Skip to content

Commit

Permalink
Merge pull request #15 from oveleon/develop
Browse files Browse the repository at this point in the history
Consider urlPrefix with disabled legacy routing for logo module
  • Loading branch information
zoglo authored Apr 13, 2022
2 parents f68af1a + dc22347 commit b8b57fb
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions src/Resources/contao/modules/ModuleLogo.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ class ModuleLogo extends Module
*/
public function generate()
{
$request = System::getContainer()->get('request_stack')->getCurrentRequest();
$request = System::getContainer()->get('request_stack')->getCurrentRequest();

if ($request && System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest($request))
{
$objTemplate = new BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### ' . mb_strtoupper($GLOBALS['TL_LANG']['FMD']['logo'][0], 'UTF-8') . ' ###';
$objTemplate->title = $this->headline;
$objTemplate->id = $this->id;
$objTemplate->link = $this->name;
$objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;

return $objTemplate->parse();
}
if ($request && System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest($request))
{
$objTemplate = new BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### ' . mb_strtoupper($GLOBALS['TL_LANG']['FMD']['logo'][0], 'UTF-8') . ' ###';
$objTemplate->title = $this->headline;
$objTemplate->id = $this->id;
$objTemplate->link = $this->name;
$objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;

return $objTemplate->parse();
}

$singleSRC = Company::get('logo');

Expand Down Expand Up @@ -94,27 +94,32 @@ protected function compile(): void

$this->addImageToTemplate($this->Template, $this->arrData, null, null, $this->objFile);

// Create rootHref URL
// Create rootHref URL
$strPageUrl = Environment::get('url');
$prependLocale = System::getContainer()->getParameter('contao.prepend_locale');

if($prependLocale)
{
$strPageUrl .= '/' . $objPage->language;
$strPageUrl .= '/' . $objPage->language;
}
// consider urlPrefix with disabled legacy routing (Contao 4.10 and up)
else if(!!$objPage->urlPrefix)
{
$strPageUrl .= '/' . $objPage->urlPrefix;
}

$strPageUrl .= '/';
$strPageUrl .= '/';

// Set URI as title tag
$strCompanyName = $strPageUrl;
// Set URI as title tag
$strCompanyName = $strPageUrl;

// Override title tag with company name if it is set
if (!empty(Company::get('name')))
{
$strCompanyName = Company::get('name');
}
// Override title tag with company name if it is set
if (!empty(Company::get('name')))
{
$strCompanyName = Company::get('name');
}

$this->Template->rootHref = $strPageUrl;
$this->Template->title = $strCompanyName;
$this->Template->rootHref = $strPageUrl;
$this->Template->title = $strCompanyName;
}
}

0 comments on commit b8b57fb

Please sign in to comment.