Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Dont use strings as uid for fake content elements #228

Merged
merged 1 commit into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions Classes/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,46 @@ class Constants

public const REPOSITORY_CONJUNCTION_OR = 'OR';
public const REPOSITORY_CONJUNCTION_AND = 'AND';

/**
* Mapping is completly made up random numbers, up to ensure
* we are not passing strings to the ContentObjectRenderer
* when we are rendering fake content elements on blog pages.
*
* We need fake content elements to ensure the rendering
* behaves on the container like every other content element.
*
* EXAMPLE:
* {blogvh:data.contentListOptions(listType: 'blog_sidebar')}
* <f:cObject typoscriptObjectPath="tt_content.list" data="{contentObjectData}" table="tt_content"/>
*
* USAGE:
* Resources/Private/Templates/Page/BlogList.html
* Resources/Private/Templates/Page/BlogPost.html
*
* NOTE:
* Numbers need to be negative to ensure records do not exit.
*/
public const LISTTYPE_TO_FAKE_UID_MAPPING = [
'blog_posts' => -1600000000,
'blog_demandedposts' => -1600000001,
'blog_latestposts' => -1600000002,
'blog_category' => -1600000003,
'blog_authorposts' => -1600000004,
'blog_archive' => -1600000005,
'blog_sidebar' => -1600000006,
'blog_commentform' => -1600000007,
'blog_comments' => -1600000008,
'blog_header' => -1600000009,
'blog_footer' => -1600000010,
'blog_metadata' => -1600000011,
'blog_authors' => -1600000012,
'blog_relatedposts' => -1600000013,
'blog_recentpostswidget' => -1600000014,
'blog_categorywidget' => -1600000015,
'blog_tagwidget' => -1600000016,
'blog_commentswidget' => -1600000017,
'blog_archivewidget' => -1600000018,
'blog_feedwidget' => -1600000019,
];
}
3 changes: 2 additions & 1 deletion Classes/ViewHelpers/Data/ContentListOptionsViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace T3G\AgencyPack\Blog\ViewHelpers\Data;

use T3G\AgencyPack\Blog\Constants;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Object\ObjectManager;
Expand Down Expand Up @@ -45,7 +46,7 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl
$data = array_merge(
$listTypeConfiguration,
[
'uid' => '-' . str_replace('_', '-', $arguments['listType']),
'uid' => Constants::LISTTYPE_TO_FAKE_UID_MAPPING[$arguments['listType']] ?? 0,
'list_type' => (string) $arguments['listType'] ?? '',
'CType' => 'list',
'layout' => $listTypeConfiguration['layout'] ?? '0',
Expand Down