well, I have prepared once something like that but never used it.
put in the frontend_render directory:
Code: Select all
<?php
/*list single entry frontend*/
function gatherExdSingle($cat, $entry_id, $template=0){
/*
$cat : Current category
$entry_id : id of entry
$template=0 : template for entries
*/
$exd =& new ExdataFrontend;
if ($template == '0') { // use default template
$event = "<div>{FIELD1} - {ENTRY1}, {ENTRY2}, {ENTRY3}, {ENTRY4}, {ENTRY5}, {ENTRY6}, {ENTRY7}, {ENTRY8}</div>";
} else {
$event = file_get_contents(PHPWCMS_ROOT."/include/inc_module/mod_exdata/inc_front/templates/".$template);
}
$sql = "SELECT * FROM " . $GLOBALS['tables']['exd_categories'] . " as cats WHERE id=$cat";
$result = mysql_query($sql)
or die("Error: ".mysql_errno().": ".mysql_error()."<hr />" . $sql);
$fieldname = mysql_fetch_array($result);
mysql_free_result($result);
/*get the visibile-list from db*/
$sql = "SELECT * FROM " . $GLOBALS['tables']['exd_cat_vis'] . " as vis WHERE catid=$cat";
$result = mysql_query($sql)
or die("Error getting visibile-list info: ".mysql_errno().": ".mysql_error()."<hr />" . $sql);
$visfield = mysql_fetch_array($result);
mysql_free_result($result);
/*get the contenttype-list from db*/
$sql = "SELECT * FROM " . $GLOBALS['tables']['exd_cat_opt'] . " WHERE catid=$cat";
$result = mysql_query($sql)
or die("Error getting category info: " . mysql_error() . "<hr />" . $sql);
$cat_dat = mysql_fetch_array($result);
mysql_free_result($result);
$events = ""; //open listing
if ($fieldname['id']==""){ //category was deleted but not the RT
return "";
}
/*number of fields in current category*/
($fieldname['cat_field_number']) ? $n = $fieldname['cat_field_number'] : $n=8; //8 = compatible to ver.1
/*get the entry from db*/
$sql = "SELECT * FROM " . $GLOBALS['tables']['exd_entries'] . " WHERE " .
"id=".$entry_id." AND catid=".$cat." AND approved=1 ";
$result = mysql_query($sql)
or die("Error: ".mysql_errno().": ".mysql_error()."<hr />" . $sql);
/*Define default or user language*/
$loc_lang = $exd->exdata_detect_lang(); //returns the local settings or default 'en-us'
$loc_lang = substr($loc_lang,0,2)."_".strtoupper(substr($loc_lang,0,2)); //use only language, not agent ($loc_lang,4,2)!
/*Date_Formattings*/
setlocale(LC_TIME, $loc_lang);
$dateform = "%x";
/*search for visible fields in case the default settings of the category is overwritten in entries*/
$row_num = array(); //the number of entries to be shown
$sort_array=array();
/*visibility-check and counting for page-menu*/
while ($row2 = mysql_fetch_array($result)) {
$iscontent=0;
$sort_temp=array();
for ($j = 1; $j <= $n; $j++) {
$invis = 0;
/*if ($visfield['field'.$j.''] == 1 && $row2['vis_field'.$j.''] !== "vis"){ //field invisible
$invis = 1;
$sort_temp['field'.$j.'']="";
}*/
if ($visfield['field'.$j.''] == 0 && $row2['vis_field'.$j.''] == "inv"){ //field invisible
$invis = 1;
$sort_temp['field'.$j.'']="";
}
if ($row2['field'.$j.'']=="0:") { //(empty articlelink)
$invis = 1;
$sort_temp['field'.$j.'']="";
}
if (($invis==0)) { //entry must be shown
//cell does exist
$sort_temp['field'.$j.'']=$row2['field'.$j.''];
$sort_temp['vis_field'.$j.'']=$row2['vis_field'.$j.''];
$iscontent++;
}
} //end for
$sort_temp['id']=$row2['id'];
if ($iscontent != 0) array_push($sort_array, $sort_temp); //add record to array
} //end while
if ($iscontent == 0) {
$sort_temp=array(); //temporary array for visibility check
$sort_temp['field1']="---";
array_push($sort_array, $sort_temp); //add record to array
}
$row_num=$sort_array;
$y=1;
$z=24;
/*start listing*/
/* start adding items to the template*/
for ($j = $y; $j <= $z; $j++) {
//when field is textarea
if ($cat_dat['field'.$j.'']==1){
$row_num[0]['field'.$j.''] = nl2br ($row_num[0]['field'.$j.'']);
$row_num[0]['field'.$j.''] = stripslashes($row_num[0]['field'.$j.'']);
//when field is wysiwyg or articlelink
} else if ($cat_dat['field'.$j.'']==2 or $cat_dat['field'.$j.'']==5) {
$row_num[0]['field'.$j.''] = stripslashes($row_num[0]['field'.$j.'']);
} else {
$row_num[0]['field'.$j.''] = stripslashes($row_num[0]['field'.$j.'']);
$row_num[0]['field'.$j.''] = htmlspecialchars($row_num[0]['field'.$j.'']);
$row_num[0]['field'.$j.''] = htmlentities($row_num[0]['field'.$j.'']);
}
//check visible
/* if ($visfield['field'.$j.''] == 1 && $row_num[0][$i]['vis_field'.$j.''] !== "vis"){ //field invisible
//cell does not exist
} else*/ if ($visfield['field'.$j.''] == 0 && $row_num[0]['vis_field'.$j.''] == "inv"){ //field invisible
//cell does not exist
} else {
//cell does exist
$event = str_replace("{FIELD".$j."}", $fieldname['field'.$j.''], $event); //fieldname
/*replace RT '{EF#}' with content depending on content type*/
switch($cat_dat['field'.$j.'']) {
default: // default
$event = str_replace("{ENTRY".$j."}", $row_num[0]['field'.$j.''], $event);
break;
case 3: //when field is date
// if ($row_num[0][$i]['field'.$j.'']) $event = str_replace("{EF".$j."}", strftime($dateform, strtotime($row_num[0][$i]['field'.$j.''])), $event);
if ($row_num[0]['field'.$j.'']) $event = str_replace("{ENTRY".$j."}", $row_num[0]['field'.$j.''], $event);
break;
case 4: //when field is link or mail
$valuelnk = explode("|", $row_num[0]['field'.$j.'']); //explode text, target
($valuelnk[2]) ? $valuelnk[2]=$valuelnk[2] : $valuelnk[2]=$valuelnk[0];
if ($valuelnk[1]=="mailto"){ //case mailto
if ($row_num[0]['field'.$j.'']) $event = str_replace("{ENTRY".$j."}", "<a href=\"mailto:".$valuelnk[0]."\">".$valuelnk[2]."</a>", $event);
} else if ($valuelnk[1]=="none"){ //case nothing
if ($row_num[0]['field'.$j.'']) $event = str_replace("{ENTRY".$j."}", $valuelnk[2], $event);
} else { //case link with target
//add http:// if not already there
if (!preg_match('/http:\/\/(.*?)\.(.*?)\.(.+)/i', $valuelnk[0]))
$valuelnk[0]="http://".$valuelnk[0];
if ($row_num[0]['field'.$j.'']) $event = str_replace("{ENTRY".$j."}", "<a href=\"".$valuelnk[0]."\" target=\"".$valuelnk[1]."\">".$valuelnk[2]."</a>", $event);
}
break;
case 5: //when field is artikellink
$valueart = explode(":", $row_num[0]['field'.$j.'']); //explode id, text
if ($valueart[0] == 0) { //case nothing
if ($row_num[0]['field'.$j.'']) $event = str_replace("{ENTRY".$j."}", $valueart[1], $event);
} else { //case articlelink
if ($row_num[0]['field'.$j.'']) $event = str_replace("{ENTRY".$j."}", "[ID ".$valueart[0]."]".$valueart[1]."[/ID]", $event);
}
break;
case 6: //when field is internal-image
$value = explode(":", $row_num[0]['field'.$j.'']); //explode id, width, height
if ($value[1]) { //check if id exists
/*get image*/
$auto_image = $exd->make_auto_image($value);
/*write image*/
$event = str_replace("{ENTRY".$j."}", $auto_image[3], $event); //3=with pop-up, else 2
} else { //no image-data
$event = str_replace("{ENTRY".$j."}", $row_num[0]['field'.$j.''], $event);
}
break;
case 7: //when field is internal file
$value = explode(":", $row_num[0]['field'.$j.'']); //explode name, id, descr
if ($value[1]) { //check if id exists
/*get file*/
$auto_filelist = $exd->make_auto_file($value);
$event = str_replace("{ENTRY".$j."}", $auto_filelist, $event);
} else { //if no file then write the string
$event = str_replace("{ENTRY".$j."}", $row_num[0]['field'.$j.''], $event);
}
break;
case 8: //when field is GoogleMaps
$value = explode(":", $row_num[0]['field'.$j.'']); //explode name, id, descr
if ($value[0]) { //check if lat exists
/*get file*/
$gmap = $exd->make_GoogleMaps($value,$cat,$row_num[0]['id']);
$event = str_replace("{ENTRY".$j."}", $gmap, $event);
} else { //if no file then write the string
$event = str_replace("{ENTRY".$j."}", $row_num[0]['field'.$j.''], $event);
}
break;
}
}
} //end for
/*clean still empty entries*/
for ($m = 1; $m <= 24; $m++) {
$event = str_replace("{FIELD".$m."}", "", $event);
$event = str_replace("{ENTRY".$m."},", "", $event);
}
return $event;
}
if( ! ( strpos($content["all"],'{EXDSINGLE')===false ) ) {
$content["all"] = preg_replace('/\{EXDSINGLE:(.+?):(.+?):(.+?)\}/ei', "gatherExdSingle(\"\$1\", \"\$2\", \"\$3\", \"0\", \"0\")" , $content["all"]);
$content["all"] = preg_replace('/\[ID (\d+)\](.*?)\[\/ID\]/e', 'get_article_idlink($1, "$2", $db);', $content["all"]);
}
?>
now change the pattern:
Code: Select all
<div>{FIELD1} - {ENTRY1}, {ENTRY2}, {ENTRY3}, {ENTRY4}, {ENTRY5}, {ENTRY6}, {ENTRY7}, {ENTRY8}</div>
for the RT to your needs
or place a template like:
Code: Select all
<div>
<table width="100%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td><strong>{FIELD1}</strong></td>
</tr>
<tr>
<td>{ENTRY1}</td>
<td>{ENTRY2}</td>
<td>{ENTRY3}</td>
<td>{ENTRY4}</td>
<td>{ENTRY5}</td>
<td>{ENTRY6}</td>
</tr>
</table>
</div>
to directory: PHPWCMS_ROOT."/include/inc_module/mod_exdata/inc_front/templates
Then in the articles use the ReplacementTag:
{EXDSINGLE:[category-id]:[article-id]:0} (uses the pattern in the code)
or
{EXDSINGLE:[category-id]:[article-id]:[template-name]}
This RT reacts to the visibilty settings in the module and shows the rendered contentparts (images, links, articlellinks, google maps, ...)