Contentsliding is not stopping at sysfolder since TYPO3 v10 - How to solve? - typo3

The TSref entry for slide explains:
Up to Version 9 of TYPO3 the sliding stopped when reaching a folder.
Beginning with TYPO3 10 this is not longer the case. See
$cObj->checkPid_badDoktypeList.
Ok, this variable is still 255 (formerly directly, now via constant PageRepository::DOKTYPE_RECYCLER).
What exactly should I see there that will help me? Or better, how to get content sliding still working like before?

You have to extend the ContentObjectRenderer class and overwrite the getSlidePids method with your own extension.
In the boot function of ext_localconf.php:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class] = [
'className' => \YourVendor\YourExtensionKey\ContentObject\ContentObjectRenderer::class
];
Then you have to create your own "Classes/ContentObject/ContentObjectRenderer.php" with:
<?php
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace YourVendor\YourExtension\ContentObject;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class ContentObjectRenderer extends \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
{
/**
* Returns all parents of the given PID (Page UID) list
*
* #param string $pidList A list of page Content-Element PIDs (Page UIDs) / stdWrap
* #param array $pidConf stdWrap array for the list
* #return string A list of PIDs
* #internal
*/
public function getSlidePids($pidList, $pidConf)
{
// todo: phpstan states that $pidConf always exists and is not nullable. At the moment, this is a false positive
// as null can be passed into this method via $pidConf. As soon as more strict types are used, this isset
// check must be replaced with a more appropriate check like empty or count.
$pidList = isset($pidConf) ? trim($this->stdWrap($pidList, $pidConf)) : trim($pidList);
if ($pidList === '') {
$pidList = 'this';
}
$tsfe = $this->getTypoScriptFrontendController();
$listArr = null;
if (trim($pidList)) {
$listArr = GeneralUtility::intExplode(',', str_replace('this', (string)$tsfe->contentPid, $pidList));
$listArr = $this->checkPidArray($listArr);
}
$pidList = [];
if (is_array($listArr) && !empty($listArr)) {
foreach ($listArr as $uid) {
$page = $tsfe->sys_page->getPage($uid);
if($page['doktype'] == PageRepository::DOKTYPE_SYSFOLDER)
break;
if (!$page['is_siteroot']) {
$pidList[] = $page['pid'];
}
}
}
return implode(',', $pidList);
}
}

Related

How do I get uid of a File Reference Object in TYPO3?

I am trying to get a file through this code $f = $resourceFactory->getFileObject($uid); but the problem is the uid is a protected field in the file reference object, as seen below so I am not able to get the uid, and getUid() obviously wont work either.
So how can I get the uid of the file reference (FAL)
/**
* A file reference object (File Abstraction Layer)
*
* #api experimental! This class is experimental and subject to change!
*/
class FileReference extends
\TYPO3\CMS\Extbase\Domain\Model\AbstractFileFolder
{
/**
* Uid of the referenced sys_file. Needed for extbase to serialize the
* reference correctly.
*
* #var int
*/
protected $uidLocal;
/**
* #param \TYPO3\CMS\Core\Resource\ResourceInterface $originalResource
*/
public function setOriginalResource(\TYPO3\CMS\Core\Resource\ResourceInterface $originalResource)
{
$this->originalResource = $originalResource;
$this->uidLocal = (int)$originalResource->getOriginalFile()->getUid();
}
/**
* #return \TYPO3\CMS\Core\Resource\FileReference
*/
public function getOriginalResource()
{
if ($this->originalResource === null) {
$this->originalResource = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileReferenceObject($this->getUid());
}
return $this->originalResource;
}
}
Given you have an instance of TYPO3\CMS\Extbase\Domain\Model\FileReference then you can use getOriginalResource() to get the wrapped TYPO3\CMS\Core\Resource\FileReference. If you need the referenced file, you can then use getOriginalFile(). Thus as a chained call:
$file = $fileReference->getOriginalResource()->getOriginalFile();
Notice that you don't have to use the ResourceFactory yourself in all of this, this is taken care of internally.
Work form me.
You can find or get file refernce uid using custom query.
In Controller :
$uid = $yourObject->getUid();
$fileReference = $this->yourRepository->getFileReferenceObject($uid);
In Repository
public function getFileRefernceHeaderLogo($uid){
$query = $this->createQuery();
$queryString = "SELECT *
FROM sys_file_reference
WHERE deleted = 0
AND hidden = 0
AND tablenames='your_table_name'
AND fieldname='your_field_name'
AND uid_foreign =".$uid;
$query->statement($queryString);
return $res = $query->execute(true);
}
In Controller
$fileRefUid = $fileReference[0]['uid'];
Here you can get uid of file reference table.It is long process.
You can also get sys_file table uid for getFileObject.like,
$sys_file_uid = $fileReference[0]['uid_local'];

TYPO3 8 show layout selection in backend preview for textmedia

I try to use and customize the CTypes of fluid_styled_content as much as possible. Therefore the select-field "Layout" is very useful to have a possibility to select some different styles (like red box, shadow, or image-stuff). But if you have some possibilities to select it is not shown in backend preview an every element is looking the same.
Is there a way to show the selected value the layout field in backend preview for textmedia?
To get this done register a hook (path: yourextension/Classes/Hooks/PageLayoutView/TextMediaCustomPreviewRenderer.php) like that:
<?php
namespace Vendor\Yourextension\Hooks\PageLayoutView;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface;
use \TYPO3\CMS\Backend\View\PageLayoutView;
/**
* Contains a preview rendering for the page module of CType="textmedia"
*/
class TextMediaCustomPreviewRenderer implements PageLayoutViewDrawItemHookInterface
{
/**
* Preprocesses the preview rendering of a content element of type "Text Media"
*
* #param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object
* #param bool $drawItem Whether to draw the item using the default functionality
* #param string $headerContent Header content
* #param string $itemContent Item content
* #param array $row Record row of tt_content
*
* #return void
*/
public function preProcess(
PageLayoutView &$parentObject,
&$drawItem,
&$headerContent,
&$itemContent,
array &$row
)
{
$pageTs = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($row['pid']);
if ($row['CType'] === 'textmedia') {
$itemContent .= '<p>Layoutversion: ' . $pageTs['TCEFORM.']['tt_content.']['layout.']['types.']['textmedia.']['addItems.'][$row['layout']] . '</p>';
if ($row['bodytext']) {
$itemContent .= $parentObject->linkEditContent(
$parentObject->renderText($row['bodytext']),
$row
) . '<br />';
}
if ($row['assets']) {
$itemContent .= $parentObject->thumbCode($row, 'tt_content', 'assets') . '<br />';
}
$drawItem = false;
}
}
}
And in your ext_localconf.php you put like that:
// Register for hook to show preview of tt_content element of CType="textmedia" in page module
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']['textmedia'] = \Vendor\Yourextension\Hooks\PageLayoutView\TextMediaCustomPreviewRenderer::class;
In my case I offer the different options of the select in pageTsconfig like that:
TCEFORM.tt_content.layout.types.textmedia.addItems {
50 = Textbox grau, Bildergalerie oben
60 = Textbox grau, Bildergalerie unten
110 = Blau, rechtsbündig
210 = Hellblau, linksbündig
220 = Rot, linksbündig
310 = Akkordeon
}
It is the better way to use correct language handling by locallang.xlf for that. If you do it like that maybe you have to change the code example a bit...
This was the result of a thread at "TYPO3 Fragen, Antworten, inoffizielle Gruppe" on Facebook. Thanks a lot to every helping hand specially to Wolfgang Klinger :-)

Filtering for seleted categories and subcategories in extbase TYPO3 frontend plugin

I am using TYPO3 8.7.
I have got an extension which allows to list events. In the list plugin settings the redactor selects the categories. He wants that all events which have the selected category or a subcategory of it assigned are show in the frontend.
I have been reading the documentation on docs.typo3.org and have been looking at the class CategoryCollection. As far as I understand, this class helps me to get the keywords for a certain record, but does not help to select records by a keyword.
I would like to filter also for subcategories because it makes the handling of the extension much easier. Let's imagine the following event categories:
course of studies
master's degree
bachaelor's degree
training
internal training
external training
The backend editor wants to have the choice to display either e.g. internal trainings or all trainings, without activating the parent categories on every event explicitly.
What is the correct way to filter for categories and its subcategories in an extbase repository to display a list of records in the frontend?
Do I have to implement the logic manually to filter for categories and subcategories?
My solution looks like this:
<?php
namespace Snowflake\Events\Domain\Repository;
/***************************************************************
* Copyright notice
*
* (c) 2018 snowflake productions gmbh <support#snowflake.ch>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\Repository;
class EventRepository extends Repository {
/**
* #param $categories
* #return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
* #throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public function findByCategoryFilter($categories)
{
$categories = array_map('intval', explode(',', $categories));
$categories = $this->expandCategories($categories);
$uids = $this->getUidsByCategories($categories);
if (count($uids) == 0)
return array();
$query = $this->createQuery();
$query->matching(
$query->in('uid', $uids)
);
return $query->execute(true);
}
/**
* Return the categories and all subcategories (recursive)
*
* #param $categories
* #return array
*/
private function expandCategories($categories)
{
// get all categories from database
/** #var QueryBuilder $queryBuilder */
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('sys_category');
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder
->select('uid', 'parent')
->from('sys_category');
$allCategoriesFromDatabase = $queryBuilder->execute()->fetchAll();
// index the categories by parent
$categoriesByParent = array();
foreach($allCategoriesFromDatabase as $categoryFromDatabase) {
$categoriesByParent[(int)$categoryFromDatabase['parent']][] = (int)$categoryFromDatabase['uid'];
}
// expand the categories to all subcategories
$categoriesToExpand = $categories;
$expandedCategories = $categories;
while(count($categoriesToExpand) > 0) {
$currentSubCategories = array();
foreach($categoriesToExpand as $category) {
foreach ($categoriesByParent[$category] as $subCategory) {
$currentSubCategories[] = $subCategory;
}
}
$categoriesToExpand = array_diff($currentSubCategories, $expandedCategories);
$expandedCategories = array_unique(array_merge($expandedCategories, $currentSubCategories));
}
return $expandedCategories;
}
/**
* This is a workaround because
*
* $query = $this->createQuery();
* $query->matching(
* $query->contains('category', $categories)
* );
* return $query->execute(true);
*
* generate a useless SQL query (equals instead of in, see first WHERE condition in subquery)
*
* SELECT `tx_events_domain_model_event`.*
* FROM `tx_events_domain_model_event` `tx_events_domain_model_event`
* WHERE (`tx_events_domain_model_event`.`uid` IN
* (SELECT `uid_foreign`
* FROM `sys_category_record_mm`
* WHERE (`uid_local` = '1,3,5,4,6')
* AND ((`sys_category_record_mm`.`tablenames` = 'tx_events_domain_model_event')
* AND (`sys_category_record_mm`.`fieldname` = 'category'))))
* AND (`tx_events_domain_model_event`.`sys_language_uid` IN (0, -1))
* AND (`tx_events_domain_model_event`.`pid` = 161)
* AND ((`tx_events_domain_model_event`.`deleted` = 0)
* AND (`tx_events_domain_model_event`.`hidden` = 0)
* AND (`tx_events_domain_model_event`.`starttime` <= 1516715340)
* AND (
* (`tx_events_domain_model_event`.`endtime` = 0)
* OR (`tx_events_domain_model_event`.`endtime` > 1516715340)))
*
* #param $categories
* #return array
*/
private function getUidsByCategories($categories) {
$result = array();
/** #var QueryBuilder $queryBuilder */
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('sys_category_record_mm');
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder
->select('uid_foreign')
->from('sys_category_record_mm')
->where(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->in('uid_local', $categories),
$queryBuilder->expr()->eq('tablenames', '\'tx_events_domain_model_event\''),
$queryBuilder->expr()->eq('fieldname', '\'category\'')
)
);
$records = $queryBuilder->execute()->fetchAll();
foreach($records as $record) {
$result[] = $record['uid_foreign'];
}
return $result;
}
}

userfunc condition for detecting mobile device

Since TYPO3 7 the condition 'device' and 'useragent' are deprecated. No I'm looking for a userFunc to use as a condition for detecting mobile devices. My aim is to hide or to show some special pages on mobile devices.
I used the extension 'contexts_wurfl' for a while but I guess that there should be 'smaller solutions'.
Thanks for any help.
You can accomplish this with TypoScript using the PAGE Object.
The code below shows you how to execute your own code before executing something else (like the template engine/content rendering etcetera).
page.01 = USER_INT
page.01 {
userFunc = TYPO3\MyExt\Utility\MobileDeviceUtility->detectMobileDevice
}
And in code:
<?php
namespace TYPO3\MyExt\Utility;
class MobileDeviceUtility {
/**
* Is Mobile Device
*
* #return boolean
*/
static public function isMobileDevice() {
// calculates if the user agent is on a mobile device
return TRUE;
}
/**
* Detect Mobile Device
*
* #param string $content
* #param array $conf
* #return void
*/
static public function detectMobileDevice($content, array $conf = NULL) {
global $TSFE;
if (self::isMobileDevice()
&& (boolean) $TSFE->page['mycustom_device_checkbox']
) {
// do something
}
}
}
OR otherwise you should create your own condition [YourVendor\YourPackage\YourCondition = var1 = value1, var2 != value2, ...].
If you would like to avoid writing a custom user function the globalString function of Typo3 can still be used in the later versions of Typo3 to access the useragent and other information like this:
[globalString = IENV:HTTP_USER_AGENT = *<User-Agent>*]
# Statements here will only affect browsers with the useragent matching <User-Agent>
[else]
# Statements here will only affect browsers with the useragent not matching <User-Agent>
[end]
Detailed documentation for conditions using globalStringcan be found here.
A Full list of variables that can be used with the globalString function can be found here.
To execute different typoscript for mobile and stationary devices I found the following snippet to be working for Typo3 8.7 LTS and 9.5 LTS:
[globalString = IENV:HTTP_USER_AGENT = *Android*]||[globalString = IENV:HTTP_USER_AGENT = *iPhone*]||[globalString = IENV:HTTP_USER_AGENT = *Mobile*]||[globalString = IENV:HTTP_USER_AGENT = *Windows Phone*]
# Statements for mobile devices only
[else]
# Statements for stationary devices only
[end]

How to select a random image from files in a directory using typoscript?

I'm using Typo3 4.5.3 and I have image files in a directory from which I want to randomly select one to display on the current page, but I can't seem to get the typoscript right to make listnum = rand work. Here's my extension template:
# Pick a random image to display
temp.banner = IMAGE
temp.banner {
file {
height = 165
width = 954
import {
filelist = {$templatePathPrefix}images/banners | jpg,jpeg,png,gif | name | | 1
listNum = rand
}
}
params = class="bannerPic"
}
If I change the listnum setting to 0, 1, etc. it inserts the corresponding img HTML into the page. Setting it to 'last' also works, but rand always inserts the first image no matter how many times I refresh. Since I can select specific images (0, 1, ...) I know the general setup works, just not the random selection.
I've seen TS for various other uses of rand which wrap the outer object in a COA_INT object, but that didn't work for me either. Did I miss something about where to place the listNum = rand? I'm pretty new at Typo3 so lots of it is still pretty opaque to me at this point (or does it show?). Thanks for any insight you can provide.
mak_stdwrapextended extension adds the possibility to use rand with listNum.
Works well on 4.5.
I would not recommend you to do a random selection via TypoScript. Since you want a random image everytime you load the page, your random element must be a USER_INT or COA_INT element and is therefore not cacheable.
A simple solution for this is to do it via JavaScript. You define a default image if JavaScript is not available on the client, and a JavaScript that randomly select an image. With this solution, you get a random image everytime, and your content is fully cacheable.
The following TypoScript code can give you some inspiration for this. It basically reads out Image-Elements from the border collumn and generates JavaScript to output them randomly. Also, the images are linkable.
lib.teaser = COA
lib.teaser.10 = CONTENT
lib.teaser.10 < styles.content.getBorder
lib.teaser.10 {
slide = -1
table=tt_content
select{
begin = 0
max = 1
#language
languageField=sys_language_uid
#from wich column
where=colPos=3
}
wrap=<div class="teaserimage">|</div>
renderObj=COA
#image with gallery function
renderObj.10 = COA
renderObj.10 {
stdWrap.required=1
# get image
10 = IMAGE
10 {
#if not empty
required=1
file.import=uploads/pics/
file.import.field=image
#file.width=266
#file.height=180
file.import.listNum = 0
stdWrap.insertData=1
params = id="imgbig_{TSFE:currentRecord}"
imageLinkWrap < tt_content.image.20.1.imageLinkWrap
imageLinkWrap.typolink.ATagParams = id="link_imgbig_{TSFE:currentRecord}"
imageLinkWrap.typolink.ATagParams.stdWrap.insertData=1
}
# standard image configuration from tt_content
10.altText < tt_content.image.20.1.altText
10.titleText < tt_content.image.20.1.titleText
10.longdescURL < tt_content.image.20.1.longdescURL
# random function for gallery images
30 = COA
30 {
stdWrap.required=1
stdWrap.dataWrap(
<script type="text/javascript">
/* <![CDATA[ */
var imgArray = new Array(|);
var randnum = Math.round(Math.random()*(imgArray.length-1));
document.getElementById('imgbig_{TSFE:currentRecord}').src ='uploads/pics/' + imgArray[randnum];
/* ]]> */
</script>
)
# first gallery image
10 = TEXT
10.field = image
10.listNum.splitChar=,
10.listNum=0
10.if.isTrue.field=image
10.if.isTrue.listNum=1
10.if.isTrue.listNum.splitChar=,
10.dataWrap = "|"
# other gallery images
20 = TEXT
20.field = image
20.split {
token = ,
cObjNum = 1
1 = COA
1.if.isPositive.data = TSFE:register|SPLIT_COUNT
1 {
10 = TEXT
10.data = current:1
10.dataWrap = ,"|"
}
}
}
# random function for gallery links
40 = COA
40 {
stdWrap.required=1
stdWrap.dataWrap(
<script type="text/javascript">
/* <![CDATA[ */
//var imgLinkArray = new Array(randnum);
var imgLinkArray = new Array(|);
if(document.getElementById('link_imgbig_{TSFE:currentRecord}')) document.getElementById('link_imgbig_{TSFE:currentRecord}').href = imgLinkArray[randnum];
/* ]]> */
</script>
)
# first gallery link
10 = TEXT
10.field = image_link
10.listNum.splitChar=,
10.listNum=0
10.dataWrap = "|"
10.typolink.parameter.field = image_link
10.typolink.returnLast = url
# other gallery links
20 = TEXT
20.field = image_link
20.split {
token = ,
cObjNum = 1
1 = COA
1.if.isPositive.data = TSFE:register|SPLIT_COUNT
1 {
10 = TEXT
10.data = current:1
10.dataWrap = ,"|"
10.typolink.parameter.data = current:1
10.typolink.returnLast = url
}
}
}
}
}
only typo3 V4.6 and above has listNum = rand in the core, see this http://forge.typo3.org/issues/16180
for typo3 V4.5 you have to extend tslib/the class.tslib_content.php
add this to localconf.php:
$TYPO3_CONF_VARS['FE']['XCLASS']['tslib/class.tslib_content.php'] = PATH_site.'fileadmin/template/class.ux_tslib_content.php';
and add this code to class.ux_tslib_content.php:
<?php
/***************************************************************
* Copyright notice
*
* (c) 1999-2008 Kasper Skaarhoj (kasperYYYY#typo3.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Contains classes for Content Rendering based on TypoScript Template configuration
*
* $Id: class.tslib_content.php 4254 2008-09-27 13:35:44Z dmitry $
* Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj
* XHTML compliant
*
* class tslib_cObj : All main TypoScript features, rendering of content objects (cObjects). This class is the backbone of TypoScript Template rendering.
*
* #author Kasper Skaarhoj <kasperYYYY#typo3.com>
*/
/**
* This class contains all main TypoScript features.
* This includes the rendering of TypoScript content objects (cObjects).
* Is the backbone of TypoScript Template rendering.
*
* There are lots of functions you can use from your include-scripts.
* The class "tslib_cObj" is normally instantiated and referred to as "cObj".
* When you call your own PHP-code typically through a USER or USER_INT cObject then it is this class that instantiates the object and calls the main method. Before it does so it will set (if you are using classes) a reference to itself in the internal variable "cObj" of the object. Thus you can access all functions and data from this class by $this->cObj->... from within you classes written to be USER or USER_INT content objects.
*
* #author Kasper Skaarhoj <kasperYYYY#typo3.com>
* #package TYPO3
* #subpackage tslib
* #link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&cHash=4ad9d7acb4
*/
class ux_tslib_cObj extends tslib_cObj{
/**
* Exploding a string by the $char value (if integer its an ASCII value) and returning index $listNum
*
* #param string String to explode
* #param string Index-number. You can place the word "last" in it and it will be substituted with the pointer to the last value. You can use math operators like "+-/*" (passed to calc())
* #param string Either a string used to explode the content string or an integer value which will then be changed into a character, eg. "10" for a linebreak char.
* #return string
*/
function listNum($content,$listNum,$char) {
$char = $char ? $char : ',';
if (t3lib_div::testInt($char)) {
$char = chr($char);
}
$temp = explode($char,$content);
$last = ''.(count($temp)-1);
if($listNum === 'rand'){ $listNum = rand(0,count($temp)-1);} //taywa added: rand feature!
$index=$this->calc(str_ireplace('last',$last,$listNum));
return $temp[$index];
}
}
?>