[TYPO3-dev] Getting id of the page
Tapio Markula
tapio.markula at dnainternet.net
Mon Aug 28 08:58:29 CEST 2006
Elmar Hinz kirjoitti:
> Tapio Markula wrote:
>> Hi
>>
>> I would need for function 'docStyle()' for class.ux_template.php
>>
>> the id of the page, which has been opened.
>> I tried to get it from $_GET parameter
>>
>
> Hi Tapio,
>
> I have made the experience, that the ID is not set in all BE module
> links like one would expect.
> I use a workaround that fetches the ID in
> some strange situations from returnUrls.
yes - it has been set in some situations quite weird.
I debugged all situations in FE editing and BE.
Making page TS Config based conditions for BE took time debugging.
> Please look into this class, it may be of help:
>
> http://typo3.org/extensions/repository/view/elba/0.5.0/info/class.tx_elba_be.php/
Well that would not help me because I make possible
to put 'toolbar' in frontend editing to pop-up window,
why I needed some extra conditions.
I need these
$_GET=t3lib_div::_GET();
if(isset($_GET['id'])) // BE: current page in several modules; FE:
always 'Web > List' + 'Page Properties', 'New page' and 'New content
element', if pop-up windows has not been used
$id = $_GET['id'];
elseif(isset($_GET['edit']['pages'])) // FE: 'Page properties' if
pop-up windows has been used
$id = key($_GET['edit']['pages']);
elseif(isset($_GET['table']) && $_GET['table']=='pages' &&
isset($_GET['uid'])) // FE: 'Move page' if pop-up windows has been used
$id = $_GET['uid'];
elseif(isset($_GET['edit']['tt_content']) &&
$_GET['returnUrl']=='close.html') { // FE: 'Create new content element'
if pop-up windows has been used
$pid=key($_GET['edit']['tt_content']);
if($_GET['edit']['tt_content'][$pid]=='new')
$id=$pid;
}
elseif(isset($_GET['element'])) // FE and BE: 'Record history'
$id = substr($_GET['element'],6);
elseif(isset($_GET['returnUrl']) && strrchr($_GET['returnUrl'],'id='))
{ // BE - 'Create new content element' and editing individual records
$id = strrchr($_GET['returnUrl'],'id='); // find the needed parameter
$id = substr($id,3); // strip off 'id='
/*
if (preg_match('/(?:^|&)id=([0-9]+)/',$_GET['returnUrl'],$match))
$id = $match[0]; // match[1] // didn't work - proposed by "Masi"
*/
if(strpos($id,'&table')) { // strip off '&table' if exists - exists
in some views
$idPos = strpos($id,'&table');
$id = substr($id,0,$idPos);
}
}
elseif(isset($_GET['edit'])) { // FE - editing other records
$key = key($_GET['edit']); // name of the table
$uid = key($_GET['edit'][$key]); // uid of the current record
$pid = t3lib_BEfunc::getRecord ($key, $uid, $fields='pid'); // pid of
the currect record getting fetched from the table
$id = $pid['pid']; // needed id value
}
elseif(isset($_GET['P']['table']) && $_GET['P']['table']=='tt_content'
&& isset($_GET['P']['pid'])) // BE - editing content in a separate window
$id = $_GET['P']['pid'];
More information about the TYPO3-dev
mailing list