Project

General

Profile

Actions

Feature #16180

closed

Add random on listNum

Added by Jean-Baptiste Rio over 18 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Should have
Category:
-
Target version:
-
Start date:
2006-05-25
Due date:
% Done:

100%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

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)

Actions #1

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);

Actions #2

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.

Actions #3

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

Actions #4

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.

Actions #5

Updated by Thomas Deinhamer over 14 years ago

bump

Would definitely be a cool feature!

Actions #6

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

see:
http://bugs.php.net/44999

Actions #7

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.

Actions #8

Updated by Chris topher over 14 years ago

I would say: Just do it! :-)

Actions #9

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

Actions #10

Updated by Chris topher over 13 years ago

  • Category deleted (Communication)
  • Target version deleted (0)
  • PHP Version deleted (5)
Actions #11

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

Actions #12

Updated by Chris topher over 13 years ago

Documentation for this feature has been added to the wiki.

Actions #13

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
}
}

Actions #14

Updated by Mario Rimann over 13 years ago

  • Status changed from Accepted to Resolved
  • % Done changed from 0 to 100
Actions #15

Updated by Steffen Gebert over 13 years ago

  • Target version set to 1281
Actions #16

Updated by Xavier Perseguers over 12 years ago

  • Status changed from Resolved to Closed
Actions #17

Updated by Ernesto Baschny over 11 years ago

  • Target version deleted (1281)
Actions

Also available in: Atom PDF