-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from fritzmg/change-template-variable
Change template variable instead of using custom templates
- Loading branch information
Showing
8 changed files
with
98 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the ContaoChangeNewsMore Bundle. | ||
* | ||
* (c) Nicolas Görlach <https://github.com/ngdot> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ContaoChangeNewsMoreBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Extension\Extension; | ||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; | ||
|
||
class ContaoChangeNewsMoreExtension extends Extension | ||
{ | ||
public function load(array $configs, ContainerBuilder $container): void | ||
{ | ||
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); | ||
$loader->load('services.yaml'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the ContaoChangeNewsMore Bundle. | ||
* | ||
* (c) Nicolas Görlach <https://github.com/ngdot> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ContaoChangeNewsMoreBundle\EventListener; | ||
|
||
use Contao\FrontendTemplate; | ||
use Contao\Module; | ||
use Contao\NewsModel; | ||
use ContaoChangeNewsMoreBundle\NewsHelper; | ||
|
||
class ParseArticlesListener | ||
{ | ||
public function __invoke(FrontendTemplate $template, array $newsEntry, Module $module): void | ||
{ | ||
if (empty($newsEntry['linktext'])) { | ||
return; | ||
} | ||
|
||
$template->more = (new NewsHelper())->getReadMoreLink($newsEntry['linktext'], NewsModel::findByPk($newsEntry['id'])); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the ContaoChangeNewsMore Bundle. | ||
* | ||
* (c) Nicolas Görlach <https://github.com/ngdot> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ContaoChangeNewsMoreBundle; | ||
|
||
use Contao\ModuleNews; | ||
use Contao\NewsModel; | ||
|
||
/** | ||
* Helper class to expose ModuleNews::generateLink() | ||
*/ | ||
class NewsHelper extends ModuleNews | ||
{ | ||
public function __construct() {} | ||
|
||
public function compile() {} | ||
|
||
public function getReadMoreLink(string $linkText, NewsModel $news): string | ||
{ | ||
return $this->generateLink($linkText, $news, false, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
services: | ||
ContaoChangeNewsMoreBundle\EventListener\ParseArticlesListener: | ||
public: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
use ContaoChangeNewsMoreBundle\EventListener\ParseArticlesListener; | ||
|
||
$GLOBALS['TL_HOOKS']['parseArticles'][] = [ParseArticlesListener::class, '__invoke']; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.