Wednesday, July 8, 2009

How to display the RSS icon inside the address bar

PROBLEM:
We wanted to display the RSS icon in the browser address bar in order to subscribe to the RSS of our website

SOLUTION:
We added the following code lines to the template of the homepage, inside the field setup:


page.headerData.1005 = HTML
page.headerData.1005.value = <link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.bioversityinternational.org/nc/rss_feeds.html?tx_push2rss3ds[channel]=Bioversity%20International%20-%20Latest%20News%20and%20Publications&tx_push2rss3ds[encoding]=utf&cHash=3ece23c705" />

Monday, July 6, 2009

How to display the field 'Corporate Author' inside the publication detail

PROBLEM:
We wanted to display the field 'Corporate Author' inside the publication detail.

SOLUTION:
We edited the class.user_bioversitypublications_pi1.php file located inside the extension folder in the following way:

$temp = $this->internal['currentRow']['corporate_author'];
if(!empty($temp)){
$markerArray['###SUBPART_COAUTHOR###'] = $temp;
$markerArray['###LABEL_CORPORATE_AUTHOR###'] = 'Corporate Author:';
}
else $markerArray['###LABEL_CORPORATE_AUTHOR###'] = '';


We edited the template.html located inside the extension folder in the following way:

<!-- ###SUBPART_COAUTHOR### -->

<b>###LABEL_CORPORATE_AUTHOR###</b> ###PUBLICATION_CORPORATE_AUTHOR###<br />

<!-- ###SUBPART_COAUTHOR### -->

Thursday, July 2, 2009

How to customize the display of the related information bar inside the pages

Problem:
When we created a page with a related information bar without content, in the right column of the page an empty related information bar was displayed.

Solution:
In order to avoid the display of an empty related information bar, we edited the typoscript of the homepage template in the following way (in the setup field):


###############
### RELATED ###
###############

lib.related = COA
lib.related.5 < lib.rel_info_bar
lib.related.stdWrap {
wrap = <div id="right-col"><h2>Highlights</h2><div id="right-col-content"> | </div></div>
required = 1
}

Wednesday, June 17, 2009

push2rss_3ds customization for items ordering and management

PROBLEM:
We wanted a different behaviour on the RSS items management and ordering.
In detail:
  • If an item was modified the RSS items related to it didn't be presented in first position.
  • If the item status was changed from hidden to published the RSS item related had to be presented on the basis of the time the status changes even if the item was created past time.
  • The extension had to manage the START/STOP publication date.
  • If the workspace definition switched from DRAFT to LIVE, the RSS item created had to be displayed in first position even if the DRAFT item was created past time.
  • The extension had to manage in the same channel different items (like publications and news) and order them in a right way.
SOLUTION:
  • We added three more column to the tx_push2rss3ds_item table:
ALTER TABLE tx_push2rss3ds_item ADD COLUMN time_order int(11);
ALTER TABLE tx_push2rss3ds_item ADD COLUMN starttime int(11);
ALTER TABLE tx_push2rss3ds_item ADD COLUMN endtime int(11);

These three new column are needed to record the values for a right order of the XML which generated the RSS items (time_order field) and to manage the START/STOP publication date.

  • We edited the class.tx_push2rss3ds_push.php file located in the push2rss3ds extension folder in the following way:
Inside the function record2rss($id,$table)we updated the code in this way:

$dbQuery2 = $GLOBALS['TYPO3_DB']->SELECTquery(
'starttime,endtime',
$table,
'uid='.$id,
'', '', ''
);

$dbRes2 = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $dbQuery2);
$dbRow2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($dbRes2);
$starttime = $dbRow2['starttime'];
$endtime = $dbRow2['endtime'];

if (($GLOBALS['TYPO3_DB']->sql_num_rows($dbRes))!=0 && $trackChanges==0){
$dbRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($dbRes);

if($dbRow['hidden']==1 && $dbRowHIDDEN==0 && $dbRow['time_order'] < $date) $dataorder = $date; else $dataorder = $dbRow['time_order']; //else if ($dbRow['hidden']==0 && $hiddenO==0) $dataorder = $updateArray = array( 'pid' => $pid,
'tstamp'=> $date,
'title'=>$dbRowTITLE,
'description'=>$dbRowDESCRIPTION,
'link'=>$dbRowLINK,
'pubdate'=>$dbRowDATE,
'optional_item'=>$option,
'md5'=>$md5,
'deleted'=>$dbRowDELETE,
'hidden'=>$dbRowHIDDEN,
'sys_language_uid'=> $dbRowLANGUAGE,
'l18n_parent' => $uidRssParent,
'time_order'=>$dataorder,
'starttime'=>$starttime,
'endtime'=>$endtime,
);


$dbQuery = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_push2rss3ds_item', 'source_id='.$id.' AND source_table="'.$table.'" AND pid='.$pid, $updateArray);
if (!$dbRes = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $dbQuery)){
print " ERREUR ".mysql_error();
}
}

else {

$insertArray = array(
'uid' => '',
'pid' => $pid,
'tstamp'=> $date,
'crdate'=> $date,
'cruser_id'=> $cruser_id,
'title'=>$dbRowTITLE,
'description'=>$dbRowDESCRIPTION,
'link'=>$dbRowLINK,
'pubdate'=>$dbRowDATE,
'optional_item'=>$option,
'md5'=>$md5,
'source_id'=> $id,
'source_table' => $table,
'sys_language_uid' => $dbRowLANGUAGE,
'l18n_parent' => $uidRssParent,
'hidden' => $dbRowHIDDEN,
'time_order'=>$date,
'starttime'=>$starttime,
'endtime'=>$endtime,
);
$dbQuery = $GLOBALS['TYPO3_DB']->INSERTquery('tx_push2rss3ds_item', $insertArray);
if (!$dbRes = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $dbQuery)){
print " ERREUR ".mysql_error();
}

  • We edited the class.tx_push2rss3ds_pi1.php file located in the push2rss3ds extension folder in the following way:
Inside the function main($content,$conf) we updated the code in this way:

while ($rowItems = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resItems)) {
if( ($rowItems['starttime'] <>time()) || ($rowItems['starttime'] < title_item =" $rowItems['title'];" description_item =" $rowItems['description'];" link_item =" $rowItems['link'];" author_item =" $rowItems['author'];">

Tuesday, June 9, 2009

How to configure push2rss_3ds for draft workspace

PROBLEM:
When a RSS item was created from draft workspace it presented a wrong content, all its metadata (i.e. author, abstract, etc.) were empty.

SOLUTION:
We edited the class.tx_push2rss3ds_push.php located inside the push2rss_3ds extension folder in the following way:

function tt_news_DescriptionWrapper(){

if($_REQUEST['data']['tt_news']){
$tmpval = array_values($_REQUEST['data']['tt_news']);
$val = $tmpval[0];
}elseif($_REQUEST['cmd']['tt_news']){
$tmpval = array_values($_REQUEST['cmd']['tt_news']);
$uid = $tmpval[0]['version']['swapWith'];
$lolduid = array_keys($_REQUEST['cmd']['tt_news']);
$olduid = $lolduid[0];

$dbQuery = $GLOBALS['TYPO3_DB']->SELECTquery(
'*',
'tt_news',
'(uid = '.$uid.' and pid=-1) or uid='.$olduid,
'', '', ''
);

if($dbRes = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $dbQuery)){
if (($GLOBALS['TYPO3_DB']->sql_num_rows($dbRes))==1){
$val=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($dbRes);
}
}
}

if($val['bodytext']!=''){
$val['bodytext'] = substr($val['bodytext'],0,300)."...";
}

$desc = "<table>";

$desc .= "<tr><td valign='top'><b>Author:</b></td><td>".$val['author']."</td></tr>";

$desc .= "<tr><td valign='top'><b>Email:</b></td><td>".$val['author_email']."</td></tr>";

$desc .= "<tr><td valign='top'><b>Description:</b></td><td>".$val['bodytext']."</td></tr>";

$desc .= "<tr><td valign='top'><b>Year:</b></td><td>".date("d-m-Y",$val['datetime'])."</td></tr>";

$desc .= "</table>";


return $desc;
}
//********************************************************************************************************************

function pub_DescriptionWrapper(){
if($_REQUEST['data']['user_bioversitypublications_data']){

$tmpval = array_values($_REQUEST['data']['user_bioversitypublications_data']);

$val = $tmpval[0];

}elseif($_REQUEST['cmd']['user_bioversitypublications_data']){

$tmpval = array_values($_REQUEST['cmd']['user_bioversitypublications_data']);

$uid = $tmpval[0]['version']['swapWith'];

$lolduid = array_keys($_REQUEST['cmd']['user_bioversitypublications_data']);

$olduid = $lolduid[0];
$dbQuery = $GLOBALS['TYPO3_DB']->SELECTquery(

'*',

'user_bioversitypublications_data',

'(uid = '.$uid.' and pid=-1) or uid='.$olduid,

'', '', ''

);
// t3lib_div::debug($dbQuery);exit;
if($dbRes = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $dbQuery)){

if (($GLOBALS['TYPO3_DB']->sql_num_rows($dbRes))==1){

$val=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($dbRes);

}

}



// t3lib_div::debug($olduid);exit;



}
if($val['abstract']!=''){

$val['abstract'] = substr($val['abstract'],0,300)."...";

}



$desc = "<table>";

$desc .= "<tr><td valign='top'><b>Author:</b></td><td>".$val['author']."</td></tr>";

$desc .= "<tr><td valign='top'><b>Abstract:</b></td><td>".$val['abstract']."</td></tr>";

$desc .= "<tr><td valign='top'><b>Publication year:</b></td><td>".$val['publication_year']."</td></tr>";

$desc .= "</table>";
return $desc;
}
//********************************************************************************************************************

function pub_TitleWrapper(){



// global $TYPO3_CONF_VARS,$TCA;

$tmpval = array_values($_REQUEST['data']['user_bioversitypublications_data']);

$val = $tmpval[0];
$desc = strip_tags($val['title']);
return $desc;
}


NOTE:
The function listed above were added previously by us to customize RSS items content; so we added the if statement to know when an item is created from draft workspace or when it's created from live workspace.

Customization of RSS items creation inside the XML

PROBLEM:
When a RSS was created inside the channel, the order of creation was not the proper one. The problem arised when an item was created swapping its version from draft to live workspace.

SOLUTION:
We edited the $resItems of the main() function inside the class.tx_push2rss3ds_pi1.php of the push2rss_3ds extension in the following way:

$resItems = $GLOBALS['TYPO3_DB']->exec_SELECTquery( '*',
'tx_push2rss3ds_item',
'NOT deleted AND NOT hidden '.$workspaceLiveCondition.' AND pid="'.$rowChannel['pid'].'"'.$whereClause2,
'', 'tstamp desc');

Friday, June 5, 2009

Page Not Found (404) Handling - Multisite

PROBLEM:
We wanted to manage the TYPO3 page not found for several sites in order to have for each site a different page not found error.
We already have installed the urltool TYPO3 extension to manage the page not found but this worked only for one website; so when we added other websites the page not found was everytime the same one.

SOLUTION:
We edited the localconf.php in the /typo3conf folder in the following way:

<?php
if($_SERVER['SERVER_NAME']=='www.bioversityinternational.org'){
$TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = '/index.php?id=605';
$TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'] = 'HTTP/1.0 404 Not Found';
}
if($_SERVER['SERVER_NAME']=='onevision.bioversity.cgiar.org'){
$TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = 'http://onevision.bioversity.cgiar.org/index.php?id=792';
$TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'] = 'HTTP/1.0 404 Not Found';
}
if($_SERVER['SERVER_NAME']=='eufgisdev.bioversity.cgiar.org'){
$TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = 'http://eufgisdev.bioversity.cgiar.org/index.php?id=881';
$TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'] = 'HTTP/1.0 404 Not Found';
}
?>

Wednesday, June 3, 2009

Fix of the publications visualization

PROBLEM:
When we created a publication without inserting an image, a '0' was displayed in the page.

SOLUTION:
We edited the class.user_bioversitypublications_pi1.php file of the user_bioversity_publication extension.

We added this code:

if(empty($markerArray['###PUBLICATION_COVER_IMAGE###'])) $markerArray['###PUBLICATION_COVER_IMAGE###']='';

inside the function singleView.

Google search customization

PROBLEM:
We wanted to use the google search on typo3 site

SOLUTION:

  • We edited a php file which runs thanks a typo3 extension:


<?php
$sites;

if ($_GET['searchsite']=='only') $sites = "zxwduu114zc";

else $sites = "agkh6mcm5ja";
$valore = $_REQUEST['q'];

?>
<!--TYPO3SEARCH_begin-->
<>Please, type in your keywords and click the Search button or press Enter to proceed.<br />
Information about Google free text search is available <a href="http://www.google.com/support/websearch/bin/answer.py?answer=134479" target="_blank">here.</a> <br />

For more tips on searching, see <a href="http://www.google.com/support/websearch/bin/answer.py?answer=136861" target="_blank">Google advanced search operators.</a> <br />
<form id="searchbox_008604332300338350491:<?php echo $sites; ?>" action="http://www.bioversityinternational.org/free_text_search/" method="GET">

<p>

<input type="hidden" name="cx" value="008604332300338350491:<?php echo $sites; ?>" />

<input type="hidden" name="cof" value="FORID:11" />



<input name="q" value="<?php echo $_REQUEST['q'];?>" type="text" c1lass="search_textbox" size="40" maxlength="255" style="margin:0px; border:solid #cccccc 1px;margin-right:20px;"/>

<input type="submit" id="search_input" name="sa" value=" Search " alt="Click here for the search"/>

<br />

</p>

<p class="text">

<input name="searchsite" type="radio" value="only" style="width:12px;" <?php if($_GET['searchsite']=='only' || $_GET['searchsite']=='') echo 'checked'; ?> />

Search in Bioversity web site only <br />

<input name="searchsite" type="radio" value="all" style="width:12px;" <?php if($_GET['searchsite']=='all') echo 'checked'; ?> />

Search in Bioversity and <a onclick="javascript:popup_show('popup', 'popup_drag', 'popup_exit','mouse',-25,-40);" style="cursor : pointer;" >Associated Web Sites </a><br /><br /><br />

<?php

if($valore!='') echo ' Search result for: <b>' .$valore.'</b>';

?></br>

</p>
</form>

<div class="sample_popup" id="popup" style="display: none;">

<div class="menu_form_header" id="popup_drag">

<img class="menu_form_exit" id="popup_exit" src="http://www.bioversityinternational.org/fileadmin/bioversity/templates/images/gsearch/form_exit.png" alt="" />
Associated Web Sites

</div>

<div class="menu_form_body">
<table>

<tr><th><a href="http://www.promusa.org/" target="blank">Promusa</a></td></tr>

<tr><th><a href="http://www.coffeegenome.org/" target="blank">International Coffee Genome Network (ICGN )</a></td></tr>

<tr><th><a href="http://www.ecpgr.cgiar.org/" target="blank">European Cooperative Programme for Plant Genetic Resources (ECPGR)</a></td></tr>

<tr><th><a href="http://www.bioversityinternational.org/networks/euforgen/" target="blank">European Forest Genetic Resources Programme (EUFORGEN)</a></td></tr>

<tr><th><a href="http://www.grpi.org/" target="blank">Genetic Resources Policy Initiative (GRPI)</a></td></tr>

<tr><th><a href="http://singer.grinfo.net/" target="blank">System-wide Information Network for Genetic Resources - (SINGER)</a></td></tr>

<tr><th><a href="http://www.croptrust.org/main/" target="blank">Global Crop Diversity Trust</a></td></tr>

<tr><th><a href="http://www.underutilized-species.org/default.asp" target="blank">Global Facilitation Unit for Underutilized Species - GFU</a></td></tr>

<tr><th><a href="http://www.cgiar-ilac.org/" target="blank">Institutional Learning and Change Initiative (ILAC)</a></td></tr>


</table>
</div>

</div>
<!-- Google Search Result Snippet Begins -->

<div id="results_008604332300338350491:<?php echo $sites; ?>"></div>

<script type="text/javascript">

<?php

echo 'var googleSearchIframeName = "results_008604332300338350491:'.$sites.'";';

echo 'var googleSearchFormName = "searchbox_008604332300338350491:'.$sites.'";';

?>

var googleSearchFrameWidth = 600;

var googleSearchFrameborder = 0;

var googleSearchDomain = "www.google.com";

var googleSearchPath = "/cse";

</script>

<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>

<!-- Google Search Result Snippet Ends -->


<!--TYPO3SEARCH_end-->


<style>
div.sample_popup { z-index: 1; }
div.sample_popup div.menu_form_header
{
border: 1px solid black;
border-bottom: none;
width: 401px;
height: 20px
line-height: 19px;
vertical-align: middle;
background: #78B027 no-repeat;
padding-left:9px;
text-decoration: none;
font-family: font-family: Trebuchet MS,Verdana,Arial,sans-serif;
font-weight: 900;
font-size: 13px;
color: #206040;
cursor: move;
}
div.sample_popup div.menu_form_body
{
width: 410px;
padding-bottom:.7em;
padding-top:.5em;
border: 1px solid black;
background: #EEFFEE no-repeat left bottom;
}
div.sample_popup img.menu_form_exit

{
float: right;
margin: 4px 5px 0px 0px;
cursor: pointer;
}
div.sample_popup table
{
width: 100%;
border-collapse: collapse;
}
div.sample_popup th
{
width: 1%;
padding: 0px 4px 1px 10px;
text-align: left;
font-family: font-family: Trebuchet MS,Verdana,Arial,sans-serif;
font-weight: 900;
font-size: 11px;
color: #004060;
}
div.sample_popup td
{
width: 99;
padding: 0px 0px 1px 0px;
}
div.sample_popup form
{
margin: 0px;
padding: 8px 10px 10px 10px;
}
div.sample_popup input.field
{
width: 95%;
border: 1px solid #808080;
font-family: font-family: Trebuchet MS,Verdana,Arial,sans-serif;
font-size: 12px;
}
div.sample_popup input.btn
{
margin-top: 2px;
border: 1px solid #808080;
background-color: #DDFFDD;
font-family: font-family: Trebuchet MS,Verdana,Arial,sans-serif;
font-size: 11px;
}
</style>




  • For "Associated Web Sites" we edited the following java script in order to have a DHTML menu:


var popup_dragging = false;
var popup_target;
var popup_mouseX;
var popup_mouseY;
var popup_mouseposX;
var popup_mouseposY;
var popup_oldfunction;

function popup_mousedown(e)
{
var ie = navigator.appName == "Microsoft Internet Explorer";

popup_mouseposX = ie ? window.event.clientX : e.clientX;
popup_mouseposY = ie ? window.event.clientY : e.clientY;
}

function popup_mousedown_window(e)
{
var ie = navigator.appName == "Microsoft Internet Explorer";

if ( ie && window.event.button != 1) return;
if (!ie && e.button != 0) return;

popup_dragging = true;
popup_target = this['target'];
popup_mouseX = ie ? window.event.clientX : e.clientX;
popup_mouseY = ie ? window.event.clientY : e.clientY;

if (ie)
popup_oldfunction = document.onselectstart;
else popup_oldfunction = document.onmousedown;

if (ie)
document.onselectstart = new Function("return false;");
else document.onmousedown = new Function("return false;");
}

function popup_mousemove(e)
{
var ie = navigator.appName == "Microsoft Internet Explorer";
var element = document.getElementById(popup_target);
var mouseX = ie ? window.event.clientX : e.clientX;
var mouseY = ie ? window.event.clientY : e.clientY;

if (!popup_dragging) return;

element.style.left = (element.offsetLeft+mouseX-popup_mouseX)+'px';
element.style.top = (element.offsetTop +mouseY-popup_mouseY)+'px';

popup_mouseX = ie ? window.event.clientX : e.clientX;
popup_mouseY = ie ? window.event.clientY : e.clientY;
}

function popup_mouseup(e)
{
var ie = navigator.appName == "Microsoft Internet Explorer";
var element = document.getElementById(popup_target);

if (!popup_dragging) return;

popup_dragging = false;

if (ie)
document.onselectstart = popup_oldfunction;
else document.onmousedown = popup_oldfunction;
}

function popup_exit(e)
{
var ie = navigator.appName == "Microsoft Internet Explorer";
var element = document.getElementById(popup_target);

popup_mouseup(e);
element.style.display = 'none';
}
function popup_show(id, drag_id, exit_id, position, x, y, position_id)
{
var element = document.getElementById(id);
var drag_element = document.getElementById(drag_id);
var exit_element = document.getElementById(exit_id);

var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth;
var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;

element.style.position = "absolute";
element.style.display = "block";

if (position == "mouse")
{
element.style.left = (document.documentElement.scrollLeft+popup_mouseposX+x)+'px';
element.style.top = (document.documentElement.scrollTop +popup_mouseposY+y)+'px';
if (element.style.visibility == "visible") {element.style.visibility = "hidden";return true;}
element.style.visibility = "visible"
}
if (position == "screen-top-left")
{
element.style.left = (document.documentElement.scrollLeft+x)+'px';
element.style.top = (document.documentElement.scrollTop +y)+'px';
}
if (position == "screen-center")
{
element.style.left = (document.documentElement.scrollLeft+(width -element.clientWidth )/2+x)+'px';
element.style.top = (document.documentElement.scrollTop +(height-element.clientHeight)/2+y)+'px';
}
drag_element['target'] = id;
drag_element.onmousedown = popup_mousedown_window;

exit_element.onclick = popup_exit;
}

if (navigator.appName == "Microsoft Internet Explorer")
document.attachEvent ('onmousedown', popup_mousedown);
else document.addEventListener('mousedown', popup_mousedown, false);

if (navigator.appName == "Microsoft Internet Explorer")
document.attachEvent ('onmousemove', popup_mousemove);
else document.addEventListener('mousemove', popup_mousemove, false);

if (navigator.appName == "Microsoft Internet Explorer")
document.attachEvent ('onmouseup', popup_mouseup);
else document.addEventListener('mouseup', popup_mouseup, false);

  • In order to have the search form inside all web site pages, we edited the typo script of the homepage template in the following way:



###############

### SEARCH ###

###############


lib.search = TEXT

lib.search.wrap (

<div class="tx-macinasearchbox-pi1">

<div id="searchBar">

<form id="searchbox_008604332300338350491:agkh6mcm5ja" action="http://www.bioversityinternational.org/google_free_text_search/" method="GET" style="margin: 0px; padding: 0px;">

<input type="hidden" name="cx" value="008604332300338350491:agkh6mcm5ja" />

<input type="hidden" name="cof" value="FORID:11" />

<input name="q" type="text" c1lass="search_textbox" size="40" maxlength="255" />

<input type="submit" id="search_input" name="sa" value=" Search " alt="Click here for the search"/>

</form>

</div>

</div>

)

Tuesday, May 26, 2009

How configure push2rss_3ds for Latest News and Latest Publicantions

PROBLEM: We wanted to customize the rss content in order to have in the rss item the following information:
  • for Latest News: Author, Email, Description, Year
  • for Latest Publications: Author, Abstract, Publication Year
SOLUTION:
We had to change the TS config of the RSS extension (note: is not Typo Script) in the following way:
  • for Publication:

    user_bioversitypublications_data {
    title = MAP
    title.map = title
    #title = FUNCTION
    #title.userFunc = tx_push2rss3ds_push->pub_TitleWrapper
    #description = MAP
    #description.map= abstract
    description = FUNCTION
    description.userFunc = tx_push2rss3ds_push->pub_DescriptionWrapper
    pubdate = MAP
    pubdate.map = tstamp
    link = LINK
    link {
    overrulePIvars.showUid = ###CURRENT_ID###
    cache = 1
    clearAnyway = 1
    altPageId = 19
    key = user_bioversitypublications_pi1
    }

    }
  • for Latest News:

    tt_news {
    title = MAP
    title.map = title
    description = FUNCTION
    description.userFunc = tx_push2rss3ds_push->tt_news_DescriptionWrapper
    #description.userFunc.att1 = bodytext
    #description = MAP
    #description = bodytext
    link = LINK
    link {
    overrulePIvars.showUid >
    overrulePIvars {
    tt_news = ###CURRENT_ID###
    #change back pid to fit your website
    backPid = ###CURRENT_PID###
    year = null
    month = null
    pS = null
    pL = null
    arc = null
    }
    cache = 1
    clearAnyway = 1
    altPageId = 21
    key= tx_ttnews
    }
    pubdate = MAP
    pubdate.map= datetime
    }

We added the following function inside the class.tx_push2rss3ds_push.php file which resides inside the extension folder:


function tt_news_DescriptionWrapper(){


$tmpval = array_values($_REQUEST['data']['tt_news']);

$val = $tmpval[0];


$val['bodytext'] = substr($val['bodytext'],0,300)."...";


$desc = "<table>";

$desc .= "<tr><td valign='top'><b>Author:</b></td><td>".$val['author']."</td></tr>";

$desc .= "<tr><td valign='top'><b>Email:</b></td><td>".$val['author_email']."</td></tr>";

$desc .= "<tr><td valign='top'><b>Description:</b></td><td>".$val['bodytext']."</td></tr>";

$desc .= "<tr><td valign='top'><b>Year:</b></td><td>".date("d-m-Y",$val['datetime'])."</td></tr>";

$desc .= "</table>";


return $desc;


}


function pub_DescriptionWrapper(){


$tmpval = array_values($_REQUEST['data']['user_bioversitypublications_data']);

$val = $tmpval[0];


$val['abstract'] = substr($val['abstract'],0,300)."...";


$desc = "<table>";

$desc .= "<tr><td valign='top'><b>Author:</b></td><td>".$val['author']."</td></tr>";

$desc .= "<tr><td valign='top'><b>Abstract:</b></td><td>".$val['abstract']."</td></tr>";

$desc .= "<tr><td valign='top'><b>Publication year:</b></td><td>".$val['publication_year']."</td></tr>";

$desc .= "</table>";


return $desc;


}


function pub_TitleWrapper(){


$tmpval = array_values($_REQUEST['data']['user_bioversitypublications_data']);

$val = $tmpval[0];


$desc = strip_tags($val['title']);


return $desc;


}

Friday, April 24, 2009

How to display list of news items with or without images - tt_news

PROBLEM: The list of latest news in tt_news uses a rigid template in html. If there are news without images, the first paragraph of the news is wrongly displayed because the placeholder of the news shifts the text on the right.

SOLUTION:
A simple trick to be inserted in the TS Config of each page where you want to remove this behavior:

page.CSS_inlineStyle (
div.news-list-item div.news-single-img {width:auto;}
.news-list-item p.news-single-imgcaption {width:200px;}
)

This will remove limits of the image box (that could be dangerous if users can upload images without limits on the sizes) but will fix in any case its caption to 200px (our default).

Wednesday, April 22, 2009

How to configure fsearchintable extension template to avoid displaying duplicated results

PROBLEM:
When we use the search form of this extension, the result pages contains results duplicated.

SOLUTION:
We added the following lines in the fesearchintable extension template under the tt_content.listItem section to display also the tt_content header:




15 = TEXT

15.field = header

15.wrap = - <b><i>|</i></b><br />

Wednesday, April 8, 2009

How configure eu_ldap extension to have right file operation permissions

PROBLEM:
When we refreshed the back end users from ldap servers using the extension eu_ldap, the extension performed a reset of the "file operation" permissions

SOLUTION:
In the file class.tx_euldap_div.php, line 554 located under ext/eu_ldap/mod1/class.tx_euldap_div.php we performed these changes:

From:
$updateArray['fileoper_perms'] = '1';
To:
$updateArray['fileoper_perms'] = '15';

Note:
If set to '1' every time we updated back-end users from ldap with that extension, users were able only to upload, copy, move, delete, rename, create and edit files.

Friday, April 3, 2009

Wrong label visualized for the "itaw_youtoubeembed" extension

PROBLEM: When selecting the "itaw_youtoubeembed" plugin in the drop-down menu is visualized the "YouTobe Video" label.

SOLUTION: We fixed the error in the "locallang_db.xml" file of the "itaw_youtoubeembed" extension . We changed and corrected in "YouTube Video" in this line of code:

...
<label index="tt_content.list_type_pi1">YouTobe Video</label>

...

Thursday, April 2, 2009

Full Screen button disabled - ah_newsext

PROBLEM: the Flash player of the "ah_newsext" had the "Full Screen" button not working.


SOLUTION: We edited the "ufo.js" file to configure the "Full Screen" parameter in this way:

/*Unobtrusive Flash Objects (UFO) v3.20 <http://www.bobbyvandersluis.com/ufo/>
Copyright 2005, 2006 Bobby van der Sluis
This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>*/

var UFO = {
req: ["movie", "width", "height", "majorversion", "build"],
opt: ["play", "loop", "menu", "quality", "scale", "salign", "wmode", "bgcolor", "base", "flashvars", "devicefont", "allowscriptaccess", "seamlesstabbing"],
optAtt: ["id", "name", "align"],
optExc: ["swliveconnect"],
ximovie: "ufo.swf",
xiwidth: "215",
xiheight: "138",
ua: navigator.userAgent.toLowerCase(),
pluginType: "",
fv: [0,0],
foList: [],

create: function(FO, id) {
if (!UFO.uaHas("w3cdom") || UFO.uaHas("ieMac")) return;
UFO.getFlashVersion();
UFO.foList[id] = UFO.updateFO(FO);
UFO.createCSS("#" + id, "visibility:hidden;");
UFO.domLoad(id);
},

updateFO: function(FO) {
if (typeof FO.xi != "undefined" && FO.xi == "true") {
if (typeof FO.ximovie == "undefined") FO.ximovie = UFO.ximovie;
if (typeof FO.xiwidth == "undefined") FO.xiwidth = UFO.xiwidth;
if (typeof FO.xiheight == "undefined") FO.xiheight = UFO.xiheight;

}
FO.mainCalled = false;
return FO;
},

domLoad: function(id) {
var _t = setInterval(function() {
if ((document.getElementsByTagName("body")[0] != null || document.body != null) && document.getElementById(id) != null) {
UFO.main(id);
clearInterval(_t);
}
}, 250);
if (typeof document.addEventListener != "undefined") {
document.addEventListener("DOMContentLoaded", function() { UFO.main(id); clearInterval(_t); } , null); // Gecko, Opera 9+
}

},

main: function(id) {
var _fo = UFO.foList[id];
if (_fo.mainCalled) return;
UFO.foList[id].mainCalled = true;
document.getElementById(id).style.visibility = "hidden";
if (UFO.hasRequired(id)) {
if (UFO.hasFlashVersion(parseInt(_fo.majorversion, 10), parseInt(_fo.build, 10))) {
if (typeof _fo.setcontainercss != "undefined" && _fo.setcontainercss == "true") UFO.setContainerCSS(id);
UFO.writeSWF(id);
}
else if (_fo.xi == "true" && UFO.hasFlashVersion(6, 65)) {
UFO.createDialog(id);
}
}
document.getElementById(id).style.visibility = "visible";
},

createCSS: function(selector, declaration) {
var _h = document.getElementsByTagName("head")[0];
var _s = UFO.createElement("style");
if (!UFO.uaHas("ieWin")) _s.appendChild(document.createTextNode(selector + " {" + declaration + "}")); // bugs in IE/Win
_s.setAttribute("type", "text/css");
_s.setAttribute("media", "screen");
_h.appendChild(_s);
if (UFO.uaHas("ieWin") && document.styleSheets && document.styleSheets.length > 0) {
var _ls = document.styleSheets[document.styleSheets.length - 1];
if (typeof _ls.addRule == "object") _ls.addRule(selector, declaration);
}

},

setContainerCSS: function(id) {
var _fo = UFO.foList[id];
var _w = /%/.test(_fo.width) ? "" : "px";
var _h = /%/.test(_fo.height) ? "" : "px";
UFO.createCSS("#" + id, "width:" + _fo.width + _w +"; height:" + _fo.height + _h +";");
if (_fo.width == "100%") {
UFO.createCSS("body", "margin-left:0; margin-right:0; padding-left:0; padding-right:0;");

}

if (_fo.height == "100%") {
UFO.createCSS("html", "height:100%; overflow:hidden;");
UFO.createCSS("body", "margin-top:0; margin-bottom:0; padding-top:0; padding-bottom:0; height:100%;");

}
}, createElement: function(el) {
return (UFO.uaHas("xml") && typeof document.createElementNS != "undefined") ? document.createElementNS("http://www.w3.org/1999/xhtml", el) : document.createElement(el);
}, createObjParam: function(el, aName, aValue) {
var _p = UFO.createElement("param");
_p.setAttribute("name", aName);
_p.setAttribute("value", aValue);
el.appendChild(_p);

},
uaHas: function(ft) {
var _u = UFO.ua;
switch(ft) {
case "w3cdom":
return (typeof document.getElementById != "undefined" && typeof document.getElementsByTagName != "undefined" && (typeof document.createElement != "undefined" || typeof document.createElementNS != "undefined"));

case "xml":
var _m = document.getElementsByTagName("meta");
var _l = _m.length;
for (var i = 0; i < _l; i++) {
if (/content-type/i.test(_m[i].getAttribute("http-equiv")) && /xml/i.test(_m[i].getAttribute("content"))) return true;
}
return false;
case "ieMac":
return /msie/.test(_u) && !/opera/.test(_u) && /mac/.test(_u);
case "ieWin":
return /msie/.test(_u) && !/opera/.test(_u) && /win/.test(_u);
case "gecko":
return /gecko/.test(_u) && !/applewebkit/.test(_u);
case "opera":
return /opera/.test(_u);
case "safari":
return /applewebkit/.test(_u);
default:
return false;
}
},

getFlashVersion: function() {
if (UFO.fv[0] != 0) return;
if (navigator.plugins && typeof navigator.plugins["Shockwave Flash"] == "object") {
UFO.pluginType = "npapi";
var _d = navigator.plugins["Shockwave Flash"].description;
if (typeof _d != "undefined") {
_d = _d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
var _m = parseInt(_d.replace(/^(.*)\..*$/, "$1"), 10);
var _r = /r/.test(_d) ? parseInt(_d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
UFO.fv = [_m, _r];
}
}

else if (window.ActiveXObject) {
UFO.pluginType = "ax";
try { // avoid fp 6 crashes
var _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
}

catch(e) {
try {
var _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
UFO.fv = [6, 0];
_a.AllowScriptAccess = "always"; // throws if fp < 6.47

}
catch(e) {
if (UFO.fv[0] == 6) return;
}
try {
var _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
}
catch(e) {}
}
if (typeof _a == "object") {
var _d = _a.GetVariable("$version"); // bugs in fp 6.21/6.23
if (typeof _d != "undefined") {
_d = _d.replace(/^\S+\s+(.*)$/, "$1").split(",");
UFO.fv = [parseInt(_d[0], 10), parseInt(_d[2], 10)];
}
}
}
},
hasRequired: function(id) {
var _l = UFO.req.length;
for (var i = 0; i < _l; i++) {
if (typeof UFO.foList[id][UFO.req[i]] == "undefined") return false;
}
return true;
},

hasFlashVersion: function(major, release) {
return (UFO.fv[0] > major || (UFO.fv[0] == major && UFO.fv[1] >= release)) ? true : false;
},
writeSWF: function(id) {
var _fo = UFO.foList[id];
var _e = document.getElementById(id);
if (UFO.pluginType == "npapi") {
if (UFO.uaHas("gecko") || UFO.uaHas("xml")){
while(_e.hasChildNodes()) {
_e.removeChild(_e.firstChild);

}

var _obj = UFO.createElement("object");
_obj.setAttribute("type", "application/x-shockwave-flash");
_obj.setAttribute("data", _fo.movie);
_obj.setAttribute("width", _fo.width);
_obj.setAttribute("height", _fo.height);
_obj.setAttribute("allowfullscreen", "true");

// alert(_obj.getAttribute("allowfullscreen"));
var _l = UFO.optAtt.length;
for (var i = 0; i < _l; i++) {
if (typeof _fo[UFO.optAtt[i]] != "undefined") _obj.setAttribute(UFO.optAtt[i], _fo[UFO.optAtt[i]]);

}

var _o = UFO.opt.concat(UFO.optExc);
var _l = _o.length;
for (var i = 0; i < _l; i++) {
if (typeof _fo[_o[i]] != "undefined") UFO.createObjParam(_obj, _o[i], _fo[_o[i]]);
}
_e.appendChild(_obj);
}
else {
var _emb = "";
var _o = UFO.opt.concat(UFO.optAtt).concat(UFO.optExc);
var _l = _o.length;
for (var i = 0; i < _l; i++) {
if (typeof _fo[_o[i]] != "undefined") _emb += ' ' + _o[i] + '="' + _fo[_o[i]] + '"';
}
_emb += ' allowfullscreen="true"';
_e.innerHTML = '<embed type="application/x-shockwave-flash" src="' + _fo.movie + '" width="' + _fo.width + '" height="' + _fo.height + '" allowfullscreen="true" pluginspage="http://www.macromedia.com/go/getflashplayer"' + _emb + '></embed>';
}

}

else if (UFO.pluginType == "ax") {
var _objAtt = "";
var _l = UFO.optAtt.length;
for (var i = 0; i < _l; i++) {
if (typeof _fo[UFO.optAtt[i]] != "undefined") _objAtt += ' ' + UFO.optAtt[i] + '="' + _fo[UFO.optAtt[i]] + '"';

}

var _objPar = "";
var _l = UFO.opt.length;
for (var i = 0; i < _l; i++) {
if (typeof _fo[UFO.opt[i]] != "undefined") _objPar += '<param name="' + UFO.opt[i] + '" value="' + _fo[UFO.opt[i]] + '" />';
}

_objPar += '<param name="allowfullscreen" value="true" />';

var _p = window.location.protocol == "https:" ? "https:" : "http:";
_e.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + _objAtt + ' allowfullscreen="true" width="' + _fo.width + '" height="' + _fo.height + '" codebase="' + _p + '//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + _fo.majorversion + ',0,' + _fo.build + ',0"><param name="movie" value="' + _fo.movie + '" />' + _objPar + '</object>';
}
},


createDialog: function(id) {
var _fo = UFO.foList[id];

UFO.createCSS("html", "height:100%; overflow:hidden;");
UFO.createCSS("body", "height:100%; overflow:hidden;");
UFO.createCSS("#xi-con", "position:absolute; left:0; top:0; z-index:1000; width:100%; height:100%; background-color:#fff; filter:alpha(opacity:75); opacity:0.75;");

UFO.createCSS("#xi-dia", "position:absolute; left:50%; top:50%; margin-left: -" + Math.round(parseInt(_fo.xiwidth, 10) / 2) + "px; margin-top: -" + Math.round(parseInt(_fo.xiheight, 10) / 2) + "px; width:" + _fo.xiwidth + "px; height:" + _fo.xiheight + "px;");

var _b = document.getElementsByTagName("body")[0];
var _c = UFO.createElement("div");
_c.setAttribute("id", "xi-con");
var _d = UFO.createElement("div");
_d.setAttribute("id", "xi-dia");
_c.appendChild(_d);
_b.appendChild(_c);

var _mmu = window.location;

if (UFO.uaHas("xml") && UFO.uaHas("safari")) {
var _mmd = document.getElementsByTagName("title")[0].firstChild.nodeValue = document.getElementsByTagName("title")[0].firstChild.nodeValue.slice(0, 47) + " - Flash Player Installation";
}

else {
var _mmd = document.title = document.title.slice(0, 47) + " - Flash Player Installation";
}

var _mmp = UFO.pluginType == "ax" ? "ActiveX" : "PlugIn";
var _uc = typeof _fo.xiurlcancel != "undefined" ? "&xiUrlCancel=" + _fo.xiurlcancel : "";
var _uf = typeof _fo.xiurlfailed != "undefined" ? "&xiUrlFailed=" + _fo.xiurlfailed : "";

UFO.foList["xi-dia"] = { movie:_fo.ximovie, width:_fo.xiwidth, height:_fo.xiheight, majorversion:"6", build:"65", flashvars:"MMredirectURL=" + _mmu + "&MMplayerType=" + _mmp + "&MMdoctitle=" + _mmd + _uc + _uf };
UFO.writeSWF("xi-dia");
},
expressInstallCallback: function() {
var _b = document.getElementsByTagName("body")[0];
var _c = document.getElementById("xi-con");
_b.removeChild(_c);
UFO.createCSS("body", "height:auto; overflow:auto;");
UFO.createCSS("html", "height:auto; overflow:auto;");
},
cleanupIELeaks: function() {
var _o = document.getElementsByTagName("object");
var _l = _o.length
for (var i = 0; i < _l; i++) {
_o[i].style.display = "none";
for (var x in _o[i]) {
if (typeof _o[i][x] == "function") {
_o[i][x] = null;

}
}
}
}
};
if (typeof window.attachEvent != "undefined" && UFO.uaHas("ieWin")) {
window.attachEvent("onunload", UFO.cleanupIELeaks);
}

Wednesday, April 1, 2009

Positioning Youtube URL in Relations tab of tt_news - ttnews_youtube

PROBLEM: For videos in tt_news from Youtube we use the extension "ttnews_youtube".
The YouTube video link for tt_news does not appear in Relations Tag but in another custom tab we created. We want all fields for youtube video in "Relations" tab.

SOLUTION:
In ext_tables.php of "ttnews_youtube" extension, we modified the addToAllTCAtypes command as follows:


t3lib_extMgm::addToAllTCAtypes("tt_news", "tx_ttnewsyoutube_youtubevideo;;;;1-1-1, tx_ttnewsyoutube_youtubewidth, tx_ttnewsyoutube_youtubeheight", "", "after:tx_ahnewsext_flash_file");

the fields tx_ttnewsyoutube_youtubevideo, etc. will be put after "tx_ahnewsext_flash_file" that is a textbox of "Relations" tab in tt_news

Button preview link in Web -> Versioning returns a wrong link

PROBLEM:
Pressing the preview link button located in Web -> Versioning returns a wrong preview URL page.

SOLUTION:
The problem was solved adding "index.php" to the string created by TYPO3 representing the URL to the page involved in the preview.

We edited the index.php located in the folder: /.../typo3conf/ext/version/cm1/

We made the followings changes:
  • line 667:
    $previewUrl =t3lib_div::getIndpEnv('TYPO3_SITE_URL').'index.php?ADMCMD_prev='.t3lib_BEfunc::compilePreviewKeyword($params, $GLOBALS['BE_USER']->user['uid']);


Adding the index.php string allowed the cms to load the correct link to see the preview of the page.

Editing dam extension to load markers for moving, deleting and copying file using the "Display batch edit options"

PROBLEM:
In the dam extension when attempting to copy, delete or move files, using the "Display batch edit options" of the DAM, in the backend interface the following markers were not loaded:
  • ###FOLDER_INFO###
  • ###CLOSE###
  • ###SAVE###
SOLUTION:
We edited the followings files located under the dam extension:

1.class.tx_dam_cmd_filecopymove.php

In the elfeif statement in line 157 we edited the code in this way:

$item = current($items);
$content.= $this->renderFormMulti($items,$item);

We added a parameters to renderFormMulti to know the path files.

Then we edited the function renderFormMulti in the following way:

$filepath = tx_dam::file_absolutePath($meta);

$count = 1;
$bl = false;

do{
if(substr($filepath,-$count,1) == '/') $bl=true;
$count++;
}while($bl==false);

$this->pObj->markers['FOLDER_INFO'] = 'File: ' . substr($filepath,0,-($count));

$this->pObj->docHeaderButtons['SAVE'] = '<input class="c-inputButton" name="_savedok">pObj->doc->backPath, 'gfx/deletedok.gif') . ' title="' . $LANG->getLL('tx_dam_cmd_filedelete.submit',1) . '" height="16" type="image" width="16">';

$this->pObj->docHeaderButtons['CLOSE'] = '<a href="http://www.blogger.com/post-create.g?blogID=968986584737843990#" onclick="jumpBack(); return false;"><img'>pObj->doc->backPath, 'gfx/closedok.gif') . ' class="c-inputButton" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.xml:labels.cancel',1).'" alt="" height="16" width="16"></img'></a>';

2.class.tx_dam_cmd_filedelete.php

In the elseif statement in line 291 we applied these changes

$item = current($items);
$content.= $this->renderFormMulti($items, $this->pObj->target,$item);


We added a parameter to renderFormMulti to know the path files.

Finally we edited the function renderFormMulti:

$filepath = tx_dam::file_absolutePath($meta);
do{
if(substr($filepath,-$count,1) == '/') $bl=true;
$count++;
}while($bl==false);
$this->pObj->markers['FOLDER_INFO'] = 'File: ' . substr($filepath,0,-($count));


After these changes the dam extension worked in the right way loading the markers.
So we will see the folder info of the file we are managing, the close and the save icons.

Wednesday, March 25, 2009

How to set “Show Flash Inline” property by default in the “ah_newsext” extension.

PROBLEM: “Show Flash Inline” by default is unchecked and to view the preview of the video in the frontend is required that this property is checked.

SOLUTION: We added and set the “default” property to 1 inside the “config” array located in the ”tx_ahnewsext_flash_inline” array in the “ext_tables.php” file:

"tx_ahnewsext_flash_inline" => Array ( ## WOP:[fields][1][fields][5][fieldname]
"exclude" => 1, ## WOP:[fields][1][fields][5][excludeField]
"label" => "LLL:EXT:ah_newsext/locallang_db.xml:tt_news.tx_ahnewsext_flash_inline", ## WOP:[fields][1][fields][5][title]
"config" => Array (
"type" => "check",
##"checkbox" => "1",
"default" => 1
)
),

Then, in order to simplify the backend interface, we removed “Show flash Inline” option changing the “ext_tables.php”:

t3lib_extMgm::addToAllTCAtypes("tt_news","tx_ahnewsext_flash_file;;;;1-1-1, tx_ahnewsext_flash_inline, tx_ahnewsext_flash_width, tx_ahnewsext_flash_height"); ##tx_ahnewsext_prev_file, tx_ahnewsext_prev_width, tx_ahnewsext_prev_height, tx_ahnewsext_flash_wo_player, tx_ahnewsext_flash_downloadlink, x_ahnewsext_flash_downloadfile, tx_ahnewsext_flash_access, tx_ahnewsext_flash_about_text

with this line of code:

t3lib_extMgm::addToAllTCAtypes("tt_news","tx_ahnewsext_flash_file;;;;1-1-1, tx_ahnewsext_flash_width, tx_ahnewsext_flash_height"); ## tx_ahnewsext_flash_inline , tx_ahnewsext_prev_file, tx_ahnewsext_prev_width, tx_ahnewsext_prev_height, tx_ahnewsext_flash_wo_player, tx_ahnewsext_flash_downloadlink, x_ahnewsext_flash_downloadfile, tx_ahnewsext_flash_access, tx_ahnewsext_flash_about_text

Monday, March 23, 2009

How to add a TAB in a backend form (for example: tt_news)

PROBLEM: How to add a TAB in tt_news backend form?
SOLUTION: in tables.php, replace the t3lib_extMgm::addToAllTCAtypes with

t3lib_extMgm::addToAllTCAtypes("tt_news","--div--;NAME_OF_MY_TAB,NAME_OF_THE_CLASS;;;;1-1-1");