Wednesday, December 2, 2009

How to enable encoding of html tags in the headlines

PROBLEM: we needed to use a html tags like italic or bold inside the headlines of the page contents of the websites, but in the frontend appear the tags without encoding.

SOLUTION: we inserted a line of code inside the setup of the main typoscript template of the web site that allows to encode all special charachters inside the title of the page contents

lib.stdheader.10.setCurrent.htmlSpecialChars = 0



Thursday, November 26, 2009

How manage the publication permalink with multiple web sites

PROBLEM:
We needed to use the publication extension for another site. When clicking on the permalink of the publication pdf, the user was redirected to the wrong website.
SOLUTION:
We edited the PERMALINK section in the following way:

if ($_SERVER["SERVER_NAME"]!='www.bioversityinternational.org') $markerArray['<!-- ###PERMALINK### -->'] = "<p><p><a href='http://development.euforgen.org/index.php?id=1677&user_bioversitypublications_pi1[showUid]=".$myuid."' title='Permanent link for bookmarking'>Permalink</a>";

else $markerArray['<!-- ###PERMALINK### -->'] = "<p><p><a href='http://www.bioversityinternational.org/index.php?id=19&user_bioversitypublications_pi1[showUid]=".$myuid."' title='Permanent link for bookmarking'>Permalink</a>";

Monday, November 9, 2009

User password recovery form

PROBLEM:
We used the feuserloginsystem TYPO3 extension in order to activate the password recovery form for the users who forgot it.
The problem was that the extension didn't provide a setup for customizing the email messages sent to the users for the password recovery.
SOLUTION:
We edited the class.tx_feuserloginsystem_pi1.php file; in details we added the following line code inside the passwordRecovery() function to format the email messages sent to the users who forgot the password:

mail($ReceiverOfTheEmail, $TextOfTheEmail,$Headers));

Note:
- The subject of the emai can be set on the backend of the extension
- The $Headers php value contains additional information like the Sender address.

Setting up the php mail command allowed us to customize the email message sent to the users who required the recovery password.

How avoid the creation of html tags inside the RSS description

PROBLEM:
When we created a news or a publication, the RSS created presented some html tag inside its description.

SOLUTION:
To solve this issue we edited the following lines of the class.tx_push2rss3ds_push.php file:

From

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

To

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

From

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

To

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

Wednesday, November 4, 2009

Editing DB Integration extension to use multiple type choise in search mask

PROBLEM:
In the DB Integration extension, using in a select query the parameter "IN", the result is generated if is matched an ID with an element in array of values.
If this array resulted from a tag, generated previously from a multiple select choice, in the case of no selection the array is empty and the query result is incorrect. The result is a list of data with a correspondence between the select field with the empty value (''), but the expected result should be different. The right result should be a correspondence between the select field and an element contains in the list of all values ('value1','value2',...,'valueN'), where the value N is the last value of the table of interest.

SOLUTION:
We follow the steps below:
  • In the result query, where the markers are replaced with the parameters of search, We set the marker of interest with an identification name as ###WFQBE_AWE_001###. Now, we can identify the marker in the code.
  • We edited the class.tx_wfqbe_results.php located in the folder p1 under the DB Integration extension:

    After the foreach statement in line 101 we added the code in this way:

    if($marker == 'WFQBE_AWE_001'){
    if(empty($markerParametri["###".$marker."###"])){
    for($j=1;$j<100;$j++) $variabile.= $j . "','";
    $variabile.= $j;
    $markerParametri["###".$marker."###"] = $variabile;
    }
    }


    if the content for the tag WFQBE_AWE_001 is empty, the variable $markerParametri["###".$marker."###"] (marker's parameters) takes the value of $variabile (an array of "100" values) . The value "100" can be change with the dynamic count of the rows for the table of interest. In this case the table contains around 15 fields and the number of record is almost static.
After these changes the DB Integration extension worked in the right way bringing the correct result for the query.

Tuesday, November 3, 2009

How force a checkbox to be selected when creating a new publication

PROBLEM:
When we created a new publication from the TYPO3 backend, sometimes the PDFs covers was not displayed in the frontend.

SOLUTION:
If editors didn't selected the checkbox 'cover' when they created the publications, the cover was not displayed so we edited the tca.php of the extension to automatically check the checkbox.
In detail we changed:

"cover" => Array (
"exclude" => 1,
"label" => "LLL:EXT:user_bioversity_publications/locallang_db.xml:user_bioversitypublications_data.cover",
"config" => Array (
"type" => "check",
)
),

with

"cover" => Array (
"exclude" => 1,
"label" => "LLL:EXT:user_bioversity_publications/locallang_db.xml:user_bioversitypublications_data.cover",
"config" => Array (
"type" => "check",
"default" => 1
)
),

How change the field ordering on the typo3 backend

PROBLEM:
We wanted to change the field ordering in a TYPO3 system folder in the backend, used to collect all our publications. The main problem was that we didn't want to change the publication extension from kickstarter.

SOLUTION:
We edited the ext_tables.php file located under the extension directory involved in our customization.

We changed:
'default_sortby' => "ORDER BY crdate",
with
'default_sortby' => "ORDER BY publishing_date DESC",

Tuesday, September 1, 2009

How to configure the "fechangepassword" extension

To install and configure the "fechangepassword" extensionthe following steps are needed:

1. in the "class.tx_fechangepassword_pi1.php" , comment the following line of code:
debug($GLOBALS['TSFE']);

2. Create a page to change the password in the root of the website. Example: Login page

3. Create for this login page an extension template, and insert in the constants editor the following lines of code:
plugin.tx_fechangepassword_pi1 {
templateFile = EXT:fechangepassword/pi1/res/template.html
}


4. Include in the extension template the static template called "frontend change password (fechangepassword)"

5. Create a content element and select "insert plugin" type.

Remember that the form to change the password is visible only if the frontend user is logged.

Friday, July 17, 2009

How to exclude pages in the navigation menu

We used the following Typo3 property in order to exclude some pages in the navigation menu:

excludeUidList =[list of UID's pages to exclude by navigation menu]

example:
lib.secMenu.excludeUidList = 1136, 1145, 1108

Thanks to this property it is possible to view the hidden pages in the menu inside the sitemap

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