Get files from selected folder in TYPO3 custom extension - typo3

I have created a field to select the folder using Flexform in my custom extension. But I am unable to display all the files inside that folder. Does anyone know about this? Please help. Here is my code to add a field for selecting the folder in Flexform.
<settings.path>
<TCEforms>
<label>LLL:EXT:file_list/Resources/Private/Language/locallang_flexform.xlf:filelist.path</label>
<config>
<type>input</type>
<renderType>inputLink</renderType>
<size>48</size>
<eval>trim</eval>
<fieldControl>
<linkPopup>
<options>
<blindLinkOptions>page,url,mail,spec,file,telephone</blindLinkOptions>
<blindLinkFields>class,target,title,params</blindLinkFields>
</options>
</linkPopup>
</fieldControl>
</config>
</TCEforms>
</settings.path>
setup.typoscript:
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:spt_gallerymanagement/Configuration/TypoScript/DataProcessors/Processors/FilesProcessor.typoscript">
plugin.tx_sptgallerymanagement_sptgallerymanagement {
view {
templateRootPaths.0 = EXT:spt_gallerymanagement/Resources/Private/Templates/
templateRootPaths.1 = {$plugin.tx_sptgallerymanagement_sptgallerymanagement.view.templateRootPath}
partialRootPaths.0 = EXT:spt_gallerymanagement/Resources/Private/Partials/
partialRootPaths.1 = {$plugin.tx_sptgallerymanagement_sptgallerymanagement.view.partialRootPath}
layoutRootPaths.0 = EXT:spt_gallerymanagement/Resources/Private/Layouts/
layoutRootPaths.1 = {$plugin.tx_sptgallerymanagement_sptgallerymanagement.view.layoutRootPath}
}
persistence {
storagePid = {$plugin.tx_sptgallerymanagement_sptgallerymanagement.persistence.storagePid}
#recursive = 1
}
features {
#skipDefaultArguments = 1
# if set to 1, the enable fields are ignored in BE context
ignoreAllEnableFieldsInBe = 0
}
mvc {
#callDefaultActionIfActionCantBeResolved = 1
}
}
# these classes are only used in auto-generated templates
plugin.tx_sptgallerymanagement._CSS_DEFAULT_STYLE (
textarea.f3-form-error {
background-color:#FF9F9F;
border: 1px #FF0000 solid;
}
input.f3-form-error {
background-color:#FF9F9F;
border: 1px #FF0000 solid;
}
.tx-spt-gallerymanagement table {
border-collapse:separate;
border-spacing:10px;
}
.tx-spt-gallerymanagement table th {
font-weight:bold;
}
.tx-spt-gallerymanagement table td {
vertical-align:top;
}
.typo3-messages .message-error {
color:red;
}
.typo3-messages .message-ok {
color:green;
}
)
FilesProcessor.typoscript:
tt_content {
examples_dataprocfiles =< lib.contentElement
examples_dataprocfiles {
templateName = Galleryview
dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
dataProcessing.10 {
folders.data = settings.path
sorting = title
as = FileList
}
}
}

you need to use a FilesProcessor in your FLUID.
just define your FLUID variable:
:
dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
dataProcessing.10 { {
folders.data = settings.path
sorting = title
as = FileList
}
:
Then you can use a partial to render that special FLUID variable.
You might get inspired by the CE 'uploads'. Therefore inspect tt_content.uploads in your TSOB (TypoScript-Object-Browser)

Related

How do I override HMENU Special setting based on layout?

I have a menu element that is set to list the selected pages.
tt_content.my_menu {
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = list
special.value.field = pages
}
}
}
How can I change this to a directory of pages when a specific layout is set?
tt_content.my_menu {
dataProcessing {
10 {
special {
override = directory
override.if.value = my-layout
override.if.equals.field = layout
}
}
}
}
I'm not sure if MenuProcessor? has stdWrap on its properties.
But it should be possible to define two processors, each with an if:
tt_content.my_menu {
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
if {
value = my-layout
equals.field = layout
negate = 1
}
special = list
special.value.field = pages
}
20 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
20 {
if {
value = my-layout
equals.field = layout
}
special = directory
special.value.field = pages
}
}
}

Get an image from a UID using typoscriptObjectPath in a Fluid template?

In my Fluid template I have a uid of a category.
How can I get an image from a field on that category?
I've tried <f:cObject typoscriptObjectPath="lib.catImage" data="{myuid}" />
Then something like:
lib.catImage = CONTENT
lib.catImage {
table = sys_category
current = 1
select {
fieldName = cat_image
}
renderObj {
???
}
}
You don't want to get CONTENT but FILES:
lib.catImage = FILES
lib.catImage {
maxItems = 1
references {
table = sys_category
uid.data = field:uid
fieldName = images
}
renderObj = TEXT
renderObj {
stdWrap.data = file:current:uid
}
}
And call it via <f:cObject typoscriptObjectPath="lib.catImage" data="{uid: {myuid}}" />

Set levels property for menu_subpages depdending on layout

I have the following typoscript configuration for the menu_subpages object:
tt_content.menu_subpages {
dataProcessing {
10 {
levels = 1
as = menu
expandAll = 1
includeSpacer = 1
}
}
}
To give the editor more flexibility I want to set the levels property depending on the selected layout of the content object. I've tried to use the CASE object but this doesn't seem to work:
tt_content.menu_subpages {
dataProcessing {
10 {
levels = CASE
levels {
key.field = layout
default = TEXT
default.value = 1
1000 = TEXT
1000.value = 7
}
...
}
}
}
Thanks for any help!
As levels is no object but a property you can't use it as an object.
Either you change it to an object:
tt_content.menu_subpages {
dataProcessing {
10 {
levels.cObject = CASE
levels.cObject {
:
}
...
}
}
}
Or you need to set the value inside a typoscript condition.
tt_content.menu_subpages {
dataProcessing {
10 {
// default:
levels = 1
...
}
}
}
[page['layout'] == 1000]
tt_content.menu_subpages.dataProcessing.10.levels = 7
[page['layout'] = 2000]
tt_content.menu_subpages.dataProcessing.10.levels = 3
[global]

Use cropVariants with FilesProcessor

I'm using the layout-field of tt_content to render textmedia in different ways. I get the images by using FilesProcessor.
tt_content.textmedia = CASE
tt_content.textmedia {
key.field = layout
default < temp.textmedia
# newElement
newElement = FLUIDTEMPLATE
newElement {
file = EXT:.../newElement.html
dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
dataProcessing.10 {
references {
table = tt_content
fieldName = assets
}
as = images
}
}
}
How can I access the cropVariants?
Arghh…
Simple solution ...
temp.textmedia < tt_content.textmedia
tt_content.textmedia = CASE
tt_content.textmedia {
key.field = layout
default < temp.textmedia
# newElement
newElement < temp.textmedia
newElement {
templateName = MasonryGallery
}
}

Image processing configuration

I need help with image processing configuration in Typo3 7.6.4. All images are being processed no matter how big they are. That causes that the images are not in original size and unsharp, renamed and copied in processed folder. I would like to configure image processing so that it is activated only if images have some specific size (px or kb/mb). For example if image have more than 1MB or if the is width more than 800px, than processed it otherwise leave it as it is and link to original file (no copy, no processing). Thanks
page.10 = FLUIDTEMPLATE
page.10 {
template = CASE
template {
key.data = levelfield:-1,backend_layout_next_level,slide
key.override.field = backend_layout
1 = FILE
1.file = fileadmin/templates/sitename/main_1_column.html
2 = FILE
2.file = fileadmin/templates/sitename/main_2_column.html
}
partialRootPath = fileadmin/templates/sitename/partials/
layoutRootPath = fileadmin/templates/sitename/layouts/
variables {
siteName = TEXT
siteName.value = sitename
header < styles.content.get
header.select.where = colPos = 0
contentMain < styles.content.get
contentMain.select.where = colPos = 1
content_column_1 < styles.content.get
content_column_1.select.where = colPos = 1
content_column_2 < styles.content.get
content_column_2.select.where = colPos = 2
footer < styles.content.get
footer.select.where = colPos = 3
}
}
tt_content {
stdWrap {
innerWrap {
cObject {
default.20.40 = CASE
default.20.40 {
key.field = layout
default = TEXT
default.value = img-responsive
}
}
}
innerWrap2 >
}
image {
20 {
1 {
params.cObject = TEXT
params.cObject {
wrap = class="|"
cObject < tt_content.stdWrap.innerWrap.cObject.default.20.40
}
sourceCollection >
sourceCollection {
big {
maxW = 5000
dataKey = big
}
small {
maxW = 500
dataKey = small
}
smallLandscape {
maxW = 800
dataKey = smallLandscape
}
}
}
maxW = 5000
}
}
}