Feature #16180
closedAdd random on listNum
100%
Description
A little patch to offer random value on listNum with the keyword 'rand' :
File class.tslib_content.php - Line 3347 and next
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(count($temp));
$index=$this->calc(eregi_replace('last',$last,$listNum));
return $temp[$index];
}
(issue imported from #M3557)
Updated by Jean-Baptiste Rio over 18 years ago
Sorry a error when i key in. You have to read :
+ if ($listNum == 'rand') $listNum = rand(0,count($temp)-1);
Updated by Christoph Lemmer about 17 years ago
Nice Feature
maybe this inspires..
http://typo3.org/documentation/document-library/extension-manuals/dam_pages/0.1.2/view/1/3/
the way the random function is realized there is more comfortable.
The usage of Listnum as Start value for rand is pretty nice.
Updated by Frans Saris about 16 years ago
What has to be done to get this feature into core?
I'm using something like this with a XCLASS but it would be nice to see this in core.
Frans
Updated by Felix Buenemann about 15 years ago
I agree this would be cool to have in core. I needed similar functionality and am now using an XCLASS as suggested by Frans.
Updated by Thomas Deinhamer over 14 years ago
bump
Would definitely be a cool feature!
Updated by taywa gmbh over 14 years ago
that would be a great feature.
the code above doesen't work anymore with php5.3 and typo3 4.4 it should read:
+ if ($listNum === 'rand') $listNum = rand(0,count($temp)-1);
because of:
if(0 == 'anystring') //returns TRUE
Updated by over 14 years ago
Is Peter Niederlag still taking care of this issue? If not I could take care for a patch and make an RFC.
Updated by Mario Rimann over 13 years ago
Just committed this change to the Gerrit review process, but somehow this wasn't mentioned here automagically:
https://review.typo3.org/2538
Updated by Chris topher over 13 years ago
- Category deleted (
Communication) - Target version deleted (
0) - PHP Version deleted (
5)
Updated by Mr. Hudson over 13 years ago
Patch set 5 of change I55efef8ed714eaa1545f9f179e18260661407de7 has been pushed to the review server.
It is available at http://review.typo3.org/2538
Updated by Chris topher over 13 years ago
Documentation for this feature has been added to the wiki.
Updated by Mario Rimann over 13 years ago
Use the following TS to test-drive the patch from Gerrit:
- Create a page and set it's subtitle field to someting comma-separated like "foo,bar,baz"
- Add a TS template record on that page with the lines below (adapt if your PAGE object is not "page")
- Clear all caches and test-drive that page in the frontend
Expected behaviour after applying the changes from Gerrit:
The subtitle field changes upon every reload
Typoscript code for testing:
page.5 = COA_INT
page.5 {
10 = TEXT
10 {
field = subtitle
stdWrap.listNum = rand
}
}
Updated by Mario Rimann over 13 years ago
- Status changed from Accepted to Resolved
- % Done changed from 0 to 100
Applied in changeset 7aec9be502bdb8f2383023c2c905fdcabe8e8848.
Updated by Xavier Perseguers over 12 years ago
- Status changed from Resolved to Closed