[TYPO3] Random Text + Image
Scotty C
superscotty19 at yahoo.com
Mon Jun 12 22:27:33 CEST 2006
Hey again,
OK it looks like I jumped the gun in celebrating. I'm
trying to setup the TS (using ck_fortune as a
template) so that the content element appears on every
page, but I'm getting some weird error. Here's what I
have in my TS so far:
---------------------------------------
includeLibs.ts_onetrandomcontent =
EXT:onet_randomcontent/pi1/class.tx_onetrandomcontent_pi1.php
subparts.FEATURE = USER_INT
subparts.FEATURE {
userFunc = tx_onetrandomcontent_pi1->main
20.source_pages = 1092
}
---------------------------------------
The error I get is:
Warning: array_rand(): First argument has to be an
array in
/public_html/typo/typo3conf/ext/onet_randomcontent/pi1/class.tx_onetrandomcontent_pi1.php
on line 68
I think my problem is that I don't know what the
variable is supposed to be named (although I've tried
pid, uid, uidInList, pidInList, and source_pages).
Here's the pi1.php file:
----------------------------------------
require_once(PATH_tslib.'class.tslib_pibase.php');
class tx_onetrandomcontent_pi1 extends tslib_pibase {
var $prefixId = 'tx_onetrandomcontent_pi1'; // Same
as class name
var $scriptRelPath =
'pi1/class.tx_onetrandomcontent_pi1.php';
// Path to this script relative to the extension dir.
var $extKey = 'onet_randomcontent';
// The extension key.
var $pi_checkCHash = TRUE;
/**
* Initial processes
*/
function main($content,$conf) {
$this->conf=$conf;
$this->pi_setPiVarDefaults();
$this->pi_loadLL();
$this->pi_initPIflexForm();
// Init FlexForm configuration for plugin
// Get source pages PID(s)
$this->source_pages = explode(",",
$this->pi_getFFvalue($this->cObj->data['pi_flexform'],
'which_pages', 'sDEF'));
// $this->myParseFunc =
t3lib_div::makeInstance('tslib_cObj');
while (list ($key, $val) =
each($this->source_pages)) {
$pid_query_apx .= " OR pid='" . $val . "'";
}
$query = $GLOBALS['TYPO3_DB']->SELECTquery (
'uid',
'tt_content',
ltrim($pid_query_apx, " OR ") .
$this->cObj->enableFields('tt_content')
);
$res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $query);
$counter = 0;
while($row = mysql_fetch_assoc($res)) {
$cont_ids[$counter] = $row['uid'];
$counter++;
}
$conf["empty_content."]["select."]["uidInList"] =
$cont_ids[array_rand($cont_ids)];
$par =
$GLOBALS['TYPO3_DB']->exec_SELECTgetRows('pid','tt_content','uid='
. $conf["empty_content."]["select."]["uidInList"]);
$conf["empty_content."]["select."]["pidInList"] =
$par[0]["pid"];
$content =
$GLOBALS['TSFE']->cObj->cObjGetSingle($conf["empty_content"],
$conf["empty_content."]);
return $this->pi_wrapInBaseClass($content);
}
}
if (defined('TYPO3_MODE') &&
$TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/onet_randomcontent/pi1/class.tx_onetrandomcontent_pi1.php'])
{
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/onet_randomcontent/pi1/class.tx_onetrandomcontent_pi1.php']);
}
----------------------------------------
Any ideas?
Thanks!
-Scott.
--- Tapio Markula <tapio.markula at dnainternet.net>
wrote:
> Scotty C wrote:
> > Thanks Tapio!
> >
> > OK I've got it installed and inserted into my page
> ...
> > but now what?? (hahaha)
>
> It uses pages, which has basic content element (type
> 'Text'),
> when you can insert text, and images and links.
> Because RTE is available easy to put links.
> ck_fortune's disadvantage is missing support
> of RTE and if your put links, they are not parsed
> as they should.
>
> > Also, is there a way to set this plugin up so that
> it
> > appears on every page? I'm thinking some
> TypoScript
> > will do it, but (again) I don't know how.
>
> you need TypoScript doing that. Then you have many
> alternatives
> - all explained in this mailing list in some other
> topics.
> _______________________________________________
> TYPO3-english mailing list
> TYPO3-english at lists.netfielders.de
>
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the TYPO3-english
mailing list