Verwandte Themen - Crosslinking von Artikeln

Alles rund um Module und Plugins in CONTENIDO 4.10.
Antworten
McHubi
Beiträge: 1223
Registriert: Do 18. Nov 2004, 23:06
Wohnort: Mettmann
Kontaktdaten:

Verwandte Themen - Crosslinking von Artikeln

Beitrag von McHubi »

Hallo zusammen,

für die 4.9er hatte ich dieses Modul bereits umgesetzt (viewtopic.php?f=99&t=36172) und es kann ebenfalls für die 4.10 verwendet werden.

Was ermöglicht dieses Modul eigentlich?
Artikeln können Schlagworte zugewiesen werden. Bei der Frontend-Ausgabe wird geschaut, ob auch andere Artikel eines dieser Schlagworte beinhalten. Ist dies der Fall, werden automatisch Verlinkungen zu diesen Artikeln in der Art einer Artikelliste ausgegeben.

Dabei kann gewählt werden, ob diese Verlinkungen lediglich eine Auflistung von Headlines sind oder zusätzlich einen Text-Teaser mit ausgeben. Die Headline der Verlinkung kann dabei auf die H1 oder den Backend-Title des Artikels festgelegt werden. Andere Content-Typen können natürlich auch in der Modul-Ausgabe ergänzt werden. Die Ausgabe erfolgt alphabetisch sortiert.

Features Backend
# Erstellen, Löschen und nachträgliches Umbenennen von Schlagworten
# Zuweisen und Entfernen von Schlagworten
# Übersicht aller Schlagworte inkl. Verlinkung der Artikel
# Übersicht aller mit dem aktuellen Artikel verlinkten weiteren Artikel

Features Frontend
# List- oder Teaser-Style (Anzahl Zeichen des Text-Teasers frei festlegbar)
# Headline beinhaltet Backend-Title oder H1 des verlinkten Artikels
# Auflistung nur, wenn Artikel auch online ist
# Alphabetische Ausgabe

SQL-Statements zum Anlegen der Datenbanktabellen

Code: Alles auswählen

CREATE TABLE IF NOT EXISTS `crosslinking_sd_keywords` (
  `id` int(255) NOT NULL AUTO_INCREMENT,
  `keyword` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
  `idarts` text COLLATE latin1_german1_ci,
  `lang` int(11) NOT NULL,
  PRIMARY KEY (`id`)
)

Code: Alles auswählen

CREATE TABLE IF NOT EXISTS `crosslinking_sd_idarts` (
  `id` int(255) NOT NULL AUTO_INCREMENT,
  `idart` int(11) NOT NULL,
  `lang` int(11) NOT NULL,
  `keywords` text CHARACTER SET latin1 COLLATE latin1_bin,
  PRIMARY KEY (`id`)
)
Modul-Eingabe
Wichtig: die Variable $frontend_url noch anpassen!

Code: Alles auswählen

/***********************************************
* crosslinking_sd input
*
* Author      :     seamless-design Markus Hübner
* Copyright   :     seamless-design Markus Hübner
* Created     :     2015-03-20
************************************************/

function getPageLink()
{
if($_SERVER['HTTPS'])
return "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
else
return "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}

$frontend_url=getPageLink();
$kw_enter_delete=htmlspecialchars(strip_tags($_POST['kw_enter_delete']));
$kw_keyword=htmlspecialchars(strip_tags($_POST['kw_keyword']));
$kw_assign_remove=htmlspecialchars(strip_tags($_POST['kw_assign_remove']));
$kw_rename_keyword_old=htmlspecialchars(strip_tags($_POST['kw_rename_keyword_old']));
$kw_rename_keyword_new=htmlspecialchars(strip_tags($_POST['kw_rename_keyword_new']));
$show_all_kw=htmlspecialchars(strip_tags($_POST['show_all_kw']));
$show_all_connected_articles=htmlspecialchars(strip_tags($_POST['show_all_connected_articles']));


$array_messages=array();
/*
echo '$kw_enter_delete: '.$kw_enter_delete.'<br/>';
echo '$kw_keyword: '.$kw_keyword.'<br/>';
echo '$kw_assign_remove: '.$kw_assign_remove.'<br/>';
echo '$kw_assign_remove_select: '.$kw_assign_remove_select.'<br/>';
echo '$kw_rename_keyword_old: '.$kw_rename_keyword_old.'<br/>';
echo '$kw_rename_keyword_new: '.$kw_rename_keyword_new.'<br/>';
echo '$show_all_kw: '.$show_all_kw.'<br/>';
echo '$show_all_connected_articles: '.$show_all_connected_articles.'<br/>';
echo '$lang: '.$lang.'<br/>';
*/



/********** FUNCTIONS begin **********/
function array_all_keywords ()
  {
  $array_all_keywords=array();
  $query = "SELECT * FROM crosslinking_sd_keywords ORDER BY keyword";
  $result = cRegistry::getDb();
  $result->query($query);
  while($result->nextRecord())
    {
    $array_row=$result->toArray();
    $array_all_keywords[]=$array_row;
    }
  return $array_all_keywords;
  }
/********** FUNCTIONS end **********/



/********** COLLECTINIG KEYWORD DATA for building options and informations begin **********/
/***** keywords of current article begin *****/
$query = "SELECT * FROM crosslinking_sd_idarts WHERE idart='$idart' AND lang='$lang'";
$result = cRegistry::getDb();
$result->query($query);
while($result->nextRecord())
  {
  $array_row=$result->toArray();
  $keywords_of_idart=$array_row['keywords'];
  }	
$array_keywords_of_idart=explode(';',$keywords_of_idart);
$array_keywords_of_idart=array_filter($array_keywords_of_idart);
asort($array_keywords_of_idart);
/***** keywords of current article end *****/
/***** keywords overall begin *****/
$array_all_keywords=array_all_keywords();
/***** keywords overall end *****/
/********** COLLECTINIG KEYWORD DATA for building options and informations end **********/



/********** DATABASE OPERATIONS begin **********/
/***** keyword enter delete begin *****/
if($kw_enter_delete=="enter" OR $kw_enter_delete=="delete")
  {
  if($kw_keyword=="") $array_messages[]=mi18n("input - message kw enter delete kw empty"); 
    else
	  {
      $kw_already_exists="false";
      $query = "SELECT * FROM crosslinking_sd_keywords WHERE keyword='$kw_keyword' AND lang='$lang'";
      $result = cRegistry::getDb();
      $result->query($query);
      while($result->nextRecord())
	    {
		$array_row=$result->toArray();
		$kw_already_exists="true";
		$kw_idarts=$array_row['idarts'];
		}
/* enter begin */
      if($kw_enter_delete=="enter")
	    {
	    if($kw_already_exists=="false")
          {
	      $insert="INSERT INTO crosslinking_sd_keywords (keyword,lang) VALUES ('$kw_keyword','$lang')";
	      if($insert = $db->query($insert)) $array_messages[]=mi18n("input - message kw enter kw insertation successful");
	        else $array_messages[]=mi18n("input - message kw enter kw insertation failed");
	      }
          else $array_messages[]=mi18n("input - message kw enter kw already exists"); 
		}
/* enter end */		
/* delete begin */
      if($kw_enter_delete=="delete")
	    {
	    if($kw_already_exists=="true")
          {
		  if($kw_idarts=="")
		    {
		    $delete="DELETE FROM crosslinking_sd_keywords WHERE keyword='$kw_keyword' AND lang='$lang'";
		    if($delete = $db->query($delete)) $array_messages[]=mi18n("input - message kw delete kw deletion successful");
              else $array_messages[]=mi18n("input - message kw delete kw deletion failed");
			}
			else
			  {
			  $links_articles="";
			  $array_kw_idarts=explode(";",$kw_idarts);
			  foreach ($array_kw_idarts AS $element)
			    {
				$obj = new cApiArticleLanguage();
	            $obj->loadByArticleAndLanguageId($element,$lang);
	            $headline_h1 = $obj->getContent("htmlhead", 1);
	            $pagetitle = $obj->getField('title');
	            $onlinestatus = $obj->getField('online');
				$links_articles.='idart: <a style="text-decoration: underline;" href="'.$frontend_url.'?idart='.$element.'&lang='.$lang.'" target="_blank">'.$element.'</a> | '.$headline_h1.' ('.$pagetitle.')<br/>';
				}
			  $array_messages[]=mi18n("input - message kw delete kw can not be deleted, it is noted for articles").'<br/>'.$links_articles; 
			  }
	      }
          else $array_messages[]=mi18n("input - message kw delete kw does not exist"); 
		}
/* delete end */				
	  }
  $array_all_keywords=array_all_keywords();
  }
/***** keyword enter delete end *****/



/***** keyword assign remove begin *****/
if($kw_assign_remove!="")
  {
  $query = "SELECT * FROM crosslinking_sd_keywords WHERE keyword='$kw_assign_remove_select' AND lang='$lang'";
  $result = cRegistry::getDb();
  $result->query($query);
  while($result->nextRecord())
	{
	$array_row=$result->toArray();
	$idarts_of_keyword=$array_row['idarts'];
	}	
  $array_idarts_of_keyword=explode(';',$idarts_of_keyword);
  $array_idarts_of_keyword = array_filter($array_idarts_of_keyword); 
  }

/* assign begin */
if($kw_assign_remove=="assign")
  {
  $assign_kw="true"; 
  if(in_array($idart,$array_idarts_of_keyword))
	{
	$array_messages[]=mi18n("input - message kw assign remove - kw already assigned").' crosslinking_sd_keywords';
	$assign_kw="false";
	}	
  if(in_array($kw_assign_remove_select,$array_keywords_of_idart))
	{
	$array_messages[]=mi18n("input - message kw assign remove - kw already assigned").' crosslinking_sd_idarts';
	$assign_kw="false";
	}	
  if($assign_kw=="true")
	{
	if($idarts_of_keyword=="") $idarts_of_keyword=$idart;
	  else $idarts_of_keyword.=';'.$idart;
	$update="UPDATE crosslinking_sd_keywords SET idarts='$idarts_of_keyword' WHERE keyword='$kw_assign_remove_select' AND lang='$lang'";
    if($update = $db->query($update)) $array_messages[]=mi18n("input - message kw assign remove - kw assign successful").' crosslinking_sd_keywords';
	  else $array_messages[]=mi18n("input - message kw assign remove - kw assign failed"). 'crosslinking_sd_keywords';
	if(empty($array_keywords_of_idart))
	  {
	  $keywords_of_idart=$kw_assign_remove_select;	
	  $insert="INSERT INTO crosslinking_sd_idarts (idart,lang,keywords) VALUES ('$idart','$lang','$keywords_of_idart')";
	  if($insert = $db->query($insert)) $array_messages[]=mi18n("input - message kw assign remove - kw assign successful").' crosslinking_sd_idarts';
	    else $array_messages[]=mi18n("input - message kw assign remove - kw assign failed").' crosslinking_sd_idarts';
	  }
	  else
	    {
	    $keywords_of_idart.=';'.$kw_assign_remove_select;	
	    $update="UPDATE crosslinking_sd_idarts SET keywords='$keywords_of_idart' WHERE idart='$idart' AND lang='$lang'";
        if($update = $db->query($update)) $array_messages[]=mi18n("input - message kw assign remove - kw assign successful").' crosslinking_sd_idarts';
	      else $array_messages[]=mi18n("input - message kw assign remove - kw assign failed").' crosslinking_sd_idarts';
		}
	$array_keywords_of_idart=explode(';',$keywords_of_idart);
	}
  $array_all_keywords=array_all_keywords();
  }
/* assign end */  
/* assign remove */
if($kw_assign_remove=="remove")
  {
  $remove_kw="true"; 
  if(!in_array($idart,$array_idarts_of_keyword))
	{
	$array_messages[]=mi18n("input - message kw assign remove - kw not assigned").' crosslinking_sd_keywords';
	$remove_kw="false";
	}	
  if(!in_array($kw_assign_remove_select,$array_keywords_of_idart))
	{
	$array_messages[]=mi18n("input - message kw assign remove - kw not assigned").' crosslinking_sd_idarts';
	$remove_kw="false";
	}	
  if($remove_kw=="true")
	{
	$key = array_search($idart,$array_idarts_of_keyword);
    if($key!==false) unset($array_idarts_of_keyword[$key]);
	$key = array_search($kw_assign_remove_select,$array_keywords_of_idart);
    if($key!==false) unset($array_keywords_of_idart[$key]);
	$array_keywords_of_idart=array_values($array_keywords_of_idart);
	$amount_of_keywords=count($array_keywords_of_idart);
	if($amount_of_keywords>0)
	  {
	  $keywords_of_idart="";
      $i=0;
	  while($i < $amount_of_keywords)
	    {
		$keywords_of_idart.=$array_keywords_of_idart[$i];
		$i++;
		if($i<$amount_of_keywords) $keywords_of_idart.=';';
	    }
	  }
	  else $keywords_of_idart="";
	if($amount_of_keywords>0)
	  {
      $update="UPDATE crosslinking_sd_idarts SET keywords='$keywords_of_idart' WHERE idart='$idart' AND lang='$lang'";
        if($update = $db->query($update)) $array_messages[]=mi18n("input - message kw assign remove - kw remove successful").' crosslinking_sd_idarts';
	      else $array_messages[]=mi18n("input - message kw assign remove - kw remove failed").' crosslinking_sd_idarts';
	  }
      else  // to avoid datacorpses: completely remove information about article - there only would be said: no keywords given. 
	    {
        $delete="DELETE FROM crosslinking_sd_idarts WHERE idart='$idart' AND lang='$lang'";
		if($delete = $db->query($delete)) $array_messages[]=mi18n("input - message kw assign remove - article deletion from database successful, no keywords").' crosslinking_sd_idarts';
          else $array_messages[]=mi18n("input - message kw assign remove - article deletion from database failed, no keywords").' crosslinking_sd_idarts';
		}  
	$key = array_search($idart,$array_idarts_of_keyword);
    if($key!==false) unset($array_idarts_of_keyword[$key]);
	$array_idarts_of_keyword=array_values($array_idarts_of_keyword);
	$amount_of_idarts=count($array_idarts_of_keyword);
	if($amount_of_idarts>0)
	  {
	  $idarts_of_keyword="";
      $i=0;
	  while($i < $amount_of_idarts)
	    {
		$idarts_of_keyword.=$array_idarts_of_keyword[$i];
		$i++;
		if($i<$amount_of_idarts) $idarts_of_keyword.=';';
	    }
	  }
	  else $idarts_of_keyword="";
	$update="UPDATE crosslinking_sd_keywords SET idarts='$idarts_of_keyword' WHERE keyword='$kw_assign_remove_select' AND lang='$lang'";
    if($update = $db->query($update)) $array_messages[]=mi18n("input - message kw assign remove - kw remove successful").' crosslinking_sd_keywords';
	  else $array_messages[]=mi18n("input - message kw assign remove - kw remove failed").' crosslinking_sd_keywords';
	}
  $array_all_keywords=array_all_keywords();
  }
/* remove end */  
/***** keyword assign remove end *****/
/***** keyword rename begin *****/
if($kw_rename_keyword_old!="" AND $kw_rename_keyword_new!="")
  {
  $rename_kw="true";
  foreach($array_all_keywords AS $array)
    {
	if($array['keyword']==$kw_rename_keyword_new)
	  {
	  $array_messages[]=mi18n("input - message kw rename - kw already existing");
	  $rename_kw="false";
	  break;
	  }
	}
  if($rename_kw=="true")
    {
	$update="UPDATE crosslinking_sd_keywords SET keyword='$kw_rename_keyword_new' WHERE keyword='$kw_rename_keyword_old' AND lang='$lang'";
    if($update = $db->query($update)) $array_messages[]=mi18n("input - message kw rename - renaming successful").' crosslinking_sd_keywords';
	  else $array_messages[]=mi18n("input - message kw rename - renaming failed").' crosslinking_sd_keywords';
	$query = "SELECT * FROM crosslinking_sd_idarts WHERE lang='$lang'";
    $result = cRegistry::getDb();
    $result->query($query);
    while($result->nextRecord())
      {
      $array_row=$result->toArray();
      $row_rename_keywords_of_idart=$array_row['keywords'];
	  $row_idart=$array_row['idart'];
	  $array_row_rename_keywords_of_idart=explode(';',$row_rename_keywords_of_idart);
	  if(in_array($kw_rename_keyword_old,$array_row_rename_keywords_of_idart))
	    {
		$key = array_search($kw_rename_keyword_old,$array_row_rename_keywords_of_idart);
        if($key!==false) $array_row_rename_keywords_of_idart[$key]=$kw_rename_keyword_new;
		$amount_of_keywords=count($array_row_rename_keywords_of_idart);
	    $keywords_of_idart="";
        $i=0;
	    while($i < $amount_of_keywords)
	      {
		  $keywords_of_idart.=$array_row_rename_keywords_of_idart[$i];
		  $i++;
		  if($i<$amount_of_keywords) $keywords_of_idart.=';';
	      }
		$update="UPDATE crosslinking_sd_idarts SET keywords='$keywords_of_idart' WHERE idart='$row_idart' AND lang='$lang'";
        if($update = $db->query($update)) $array_messages[]=mi18n("input - message kw rename - renaming successful").' crosslinking_sd_idarts idart: '.$row_idart;
	      else $array_messages[]=mi18n("input - message kw rename - renaming failed").' crosslinking_sd_idarts idart: '.$row_idart;
		if($idart==$row_idart)
		  {
		  $key = array_search($kw_rename_keyword_old,$array_keywords_of_idart);
          if($key!==false) $array_keywords_of_idart[$key]=$kw_rename_keyword_new;
		  }
		}
      }	
    $array_all_keywords=array_all_keywords();
    }
  }
/***** keyword rename end *****/
/********** DATABASE OPERATIONS end **********/



/********** SHOWING MESSAGES begin **********/
if(count($array_messages)>0)
  {
  echo '<div style="background-color: #efefef; padding: 1em;"><ul style="padding-left: 1em;">';
  foreach($array_messages AS $message) echo '<li>'.$message.'</li>'; 
  echo '</ul></div>'; 
  }
/********** SHOWING MESSAGES end **********/



/********** WORKBENCH begin **********/
echo mi18n("input - idart of this article").': '.$idart.'<br/><br/>';
/***** new keyword/ delete keyword begin *****/
echo '<strong>'.mi18n("input - kw enter del headline").'</strong><br/>';
echo '<table><tr>';
echo '<td><input name="kw_keyword" type="text" size="20"></input></td>';
echo '<td><input type="radio" name="kw_enter_delete" value="enter"> '.mi18n("input - kw enter delete enter").'<br/>';
echo '<input type="radio" name="kw_enter_delete" value="delete"> '.mi18n("input - kw enter delete delete").'</td>';
echo '<td><input type="image" src="images/submit.gif"></td>';
echo '</tr></table>';
/***** new keyword/ delete keyword begin *****/



/***** assign remove keyword begin *****/
echo '<strong>'.mi18n("input - kw assign remove headline").'</strong><br/>';
echo '<table><tr>';
echo '<td><select name="kw_assign_remove_select">';
echo '<option value="">---?---</option>';
foreach ($array_all_keywords as $keyword) {
echo '<option value="'.$keyword[keyword].'">'.$keyword[keyword].'</option>';
}
echo '</select></td>';
echo '<td><input type="radio" name="kw_assign_remove" value="assign"> '.mi18n("input - kw assign remove - assign").'<br/>';
echo '<input type="radio" name="kw_assign_remove" value="remove"> '.mi18n("input - kw assign remove - remove").'</td>';
echo '<td><input type="image" src="images/submit.gif"></td>';
echo '</tr></table>';
/***** assign remove keyword end *****/



/***** rename keyword begin *****/
echo '<strong>'.mi18n("input - kw rename headline").'</strong><br/>';
echo '<table><tr>';
echo '<td>'.mi18n("input - kw rename kw old").'</td><td>'.mi18n("input - kw rename kw new").'</td><td></td></tr>';
echo '<tr>';
echo '<td><select name="kw_rename_keyword_old">';
echo '<option value="">---?---</option>';
foreach ($array_all_keywords as $keyword) {
echo '<option value="'.$keyword[keyword].'">'.$keyword[keyword].'</option>';
}
echo '</select></td>';
echo '<td><input name="kw_rename_keyword_new" type="text" size="20"></input></td>';
echo '<td><input type="image" src="images/submit.gif"></td>';
echo '</tr></table>';
/***** rename keyword end *****/



/***** list all keywords assigned to aricle begin *****/
echo '<strong>'.mi18n("input - list all kw assigned to article headline").'</strong><br/>';
if(count($array_keywords_of_idart)>0)
  {
  asort($array_keywords_of_idart);
  foreach($array_keywords_of_idart AS $keyword) echo '<span style="background-color: #ffffff; border: 1px solid #999999; padding: 0.1em;margin-right: 0.5em; font-size: 0.8em;">'.$keyword.'</span>';
  }
  else echo mi18n("input - no keywords assigned to article");
/***** list all keywords assigned to aricle end *****/



/***** list all keywords begin *****/
echo '<br/><br/><strong>'.mi18n("input - all kw headline").'</strong> ';
echo '<input type="checkbox" name="show_all_kw" value="true"';
if($show_all_kw=="true") echo ' checked="checked"';
echo '/> <input type="image" src="images/submit.gif"><br/>';
if($show_all_kw=="true")
  {
  echo '<table style="border-collapse: collapse;">';
  echo '<tr><td style="padding:0.1em;border: 1px solid #999999;">'.mi18n("input - all kw keyword").'</td><td style="padding:0.1em;border: 1px solid #999999;">'.mi18n("input - all kw idarts").'</td><td style="padding:0.1em;border: 1px solid #999999;">'.mi18n("input - all kw amount joined idarts").'</td></tr>';
  foreach($array_all_keywords AS $keyword)
    {
    echo '<tr><td style="padding:0.1em;">'.$keyword['keyword'].'</td><td style="padding:0.1em;">';
	$array_kw_idarts=explode(";",$keyword['idarts']);
	asort($array_kw_idarts);
	$array_kw_idarts = array_filter($array_kw_idarts);
    foreach ($array_kw_idarts AS $element) echo '<a style="text-decoration: underline;" href="'.$frontend_url.'?idart='.$element.'&lang='.$lang.'" target="_blank">'.$element.'</a>&nbsp;|&nbsp;';
	echo '</td><td style="padding:0.1em;">';
	echo count($array_kw_idarts);
	echo '</td></tr>';
    }
  echo '</table>';
  }
/***** list all keywords  end *****/



/***** list all connected articles begin *****/
echo '<br/><br/><strong>'.mi18n("input - all connected articles headline").'</strong> ';
echo '<input type="checkbox" name="show_all_connected_articles" value="true"';
if($show_all_connected_articles=="true") echo ' checked="checked"';
echo '/> <input type="image" src="images/submit.gif"><br/>';
if($show_all_connected_articles=="true")
  {
  $array_connected_articles=array();
  foreach($array_keywords_of_idart AS $keyword)
    {
	$query = "SELECT * FROM crosslinking_sd_keywords WHERE keyword='$keyword' AND lang='$lang'";
    $result = cRegistry::getDb();
    $result->query($query);
    while($result->nextRecord())
      {
      $array_row=$result->toArray();
	  $array_idarts_of_keyword=explode(';',$array_row['idarts']);
	  $array_connected_articles=array_merge($array_idarts_of_keyword,$array_connected_articles);
	  }
	}
  $array_connected_articles=array_unique($array_connected_articles);
  asort($array_connected_articles);
  echo '<table style="border-collapse: collapse;">';
  echo '<tr>
        <td style="padding:0.1em;border: 1px solid #999999;">'.mi18n("input - all connected articles idart").'</td>
		<td colspan="2" style="padding:0.1em;border: 1px solid #999999;">'.mi18n("input - all connected articles h1 backend title").'</td>
		<td style="padding:0.1em;border: 1px solid #999999;">'.mi18n("input - all connected articles online-status").'</td>
		</tr>';
  foreach($array_connected_articles AS $article_idart)
    {
	if($article_idart!=$idart)
	  {
	  //http://api.contenido.org/con495/class-cApiArticleLanguage.html
	  $obj = new cApiArticleLanguage();
	  $obj->loadByArticleAndLanguageId($article_idart,$lang);
	  $headline_h1 = $obj->getContent("htmlhead", 1);
	  $pagetitle = $obj->getField('title');
	  $onlinestatus = $obj->getField('online');
	  echo '<tr><td><a style="text-decoration: underline;" href="'.$frontend_url.'?idart='.$article_idart.'&lang='.$lang.'" target="_blank">'.$article_idart.'</a></td><td>H1:<br/>Backend-Title:</td><td>'.$headline_h1.'<br/>'.$pagetitle.'</td><td>'.$onlinestatus.'</td></tr>';
	  }
	}
  echo '</table>';
  }
/***** list all connected articles end *****/
/********** WORKBENCH end **********/
Modul-Ausgabe

Code: Alles auswählen

<?php
/***********************************************
* crosslinking_sd output
*
* Author      :     seamless-design Markus Hübner
* Copyright   :     seamless-design Markus Hübner
* Created     :     2015-03-20
************************************************/

//$display_by="backend_title";
$display_by="headline_h1";
$show_teaser="true"; // true or false
$teaser_length=200;

$query = "SELECT keywords FROM crosslinking_sd_idarts WHERE idart='$idart' AND lang='$lang'";
$result = cRegistry::getDb();
$result->query($query);
while($result->nextRecord())
  {
  $array_row=$result->toArray();
  $keywords_of_idart=$array_row['keywords'];
  }	
$array_keywords_of_idart=explode(';',$keywords_of_idart);
$array_keywords_of_idart=array_filter($array_keywords_of_idart);

if(count($array_keywords_of_idart)>0)
  {
  $array_connected_articles=array();
  foreach($array_keywords_of_idart AS $keyword)
    {
	$query = "SELECT idarts FROM crosslinking_sd_keywords WHERE keyword='$keyword' AND lang='$lang'";
    $result = cRegistry::getDb();
    $result->query($query);
    while($result->nextRecord())
      {
      $array_row=$result->toArray();
	  $array_idarts_of_keyword=explode(';',$array_row['idarts']);
	  $array_connected_articles=array_merge($array_idarts_of_keyword,$array_connected_articles);
	  }
	}
  $array_connected_articles=array_unique($array_connected_articles);
	  if(count($array_connected_articles)>1) // 1: if the current article got a keyword, it will always be within this array - but will not be displayed afterwards. so there has be be at least one more article in this array.
  {
  $array_display_connected_articles=array();
  $article_key=1; // needed for unique key in array, if two or more articles have same headline or backend-title!
  foreach($array_connected_articles AS $article_idart)
    {
	if($article_idart!=$idart)
	  {
	  //http://api.contenido.org/con495/class-cApiArticleLanguage.html
	  $obj = new cApiArticleLanguage();
	  $obj->loadByArticleAndLanguageId($article_idart,$lang);
	  $headline_h1 = $obj->getContent("htmlhead", 1);
	  $pagetitle = $obj->getField('title');
	  $onlinestatus = $obj->getField('online');
	  $html_1 = $obj->getContent("html", 1);
      if($onlinestatus=="1")
	    {
	    if($display_by=="headline_h1") $array_display_connected_articles[$headline_h1.'_'.$article_key]=array($article_idart,$headline_h1,$html_1);
	    if($display_by=="backend_title") $array_display_connected_articles[$pagetitle.'_'.$article_key]=array($article_idart,$pagetitle,$html_1);
	    }
      $article_key++;
	  }
	}
  ksort($array_display_connected_articles);
  echo '<div class="cl_sd_box_links">';
  echo '<h3>'.mi18n("output - linkbox headline").'</h3>';
  if($show_teaser=="true")
    {
    foreach($array_display_connected_articles AS $link_article)
      {
	  echo '<div class="cl_sd_box_links_item">';
        echo '<a href="front_content.php?idart='.$link_article[0].'&lang='.$lang.'">'.$link_article[1].'</a>';
	    echo '<div class="cl_sd_box_links_item_teaser">';
	    echo substr(strip_tags($link_article[2]),0,$teaser_length).'...';
	    echo '</div>';
	  echo '</div>';
	  }
	}
    else
	  {
	  echo '<ul>';
	  foreach($array_display_connected_articles AS $link_article) echo '<li><a href="front_content.php?idart='.$link_article[0].'&lang='.$lang.'">'.$link_article[1].'</a></li>';
	  echo '</ul>';
      }
  echo '</div>';
  }
  }
?>
CSS

Code: Alles auswählen

div.cl_sd_box_links {
clear: both;
margin-top: 2em;
}
div.cl_sd_box_links_item {
margin-top: 0.5em;
padding: 0.5em;
border: 1px solid #999999;
}
div.cl_sd_box_links_item a {
color: #000000;
}
div.cl_sd_box_links_item a:hover {
color: #ff0000;
}
div.cl_sd_box_links_item_teaser {
font-size: 0.9em;
}

div.cl_sd_box_links ul li a {
color: #000000;
text-decoration: none;
}
div.cl_sd_box_links ul li a:hover {
color: #ff0000;
text-decoration: underline;
}
lang_de_DE.txt

Code: Alles auswählen

input - all connected articles h1 backend title=H1 und Backend-Title
input - all connected articles headline=Übersicht aller mit diesem Artikel verknüpften Artikel
input - all connected articles idart=idart
input - all connected articles online-status=1: online / 0: offline (im Frontend nicht verlinkt)
input - all kw amount joined idarts=Verknüpfte Artikel
input - all kw headline=Übersicht aller Schlagworte
input - all kw idarts=idarts der Webartikel
input - all kw keyword=Schlagwort
input - idart of this article=idart dieses Artikels
input - kw assign remove - assign=zuweisen
input - kw assign remove - remove=entfernen
input - kw assign remove headline=Schlagwort zuweisen oder entfernen
input - kw enter del headline=Schlagwort eintragen/löschen
input - kw enter delete delete=löschen
input - kw enter delete enter=eintragen
input - kw rename headline=Schlagwort umbenennen
input - kw rename kw new=neu
input - kw rename kw old=alt
input - list all kw assigned to article headline=Alle diesem Artikel zugewiesenen Schlagworte.
input - message kw assign remove - article deletion from database failed, no keywords=Artikel hat keine Schlagworte mehr zugewiesen. Entfernung aus Datenbanktabelle zu Schlagworten fehlgeschlagen.
input - message kw assign remove - article deletion from database successful, no keywords=Artikel hat keine Schlagworte mehr zugewiesen. Entfernung aus Datenbanktabelle zu Schlagworten erfolgreich.
input - message kw assign remove - kw already assigned=Das Schlagwort ist dem Artikel bereits zugewiesen.
input - message kw assign remove - kw assign failed=Zuordnung des Schlagwortes fehlgeschlagen.
input - message kw assign remove - kw assign successful=Zuordnung des Schlagwortes war erfolgreich.
input - message kw assign remove - kw not assigned=Schlagwort wurde dem Artikel noch nicht zugeordnet, Aufhebung nicht möglich.
input - message kw assign remove - kw remove failed=Aufheben der Schlagwortzuordnung fehlgeschlagen.
input - message kw assign remove - kw remove successful=Aufheben der Schlagwortzuordnung war erfolgreich.
input - message kw delete kw can not be deleted, it is noted for articles=Das Schlagwort kann nicht gelöscht werden. Es ist einem oder mehreren Artikeln zugeordnet:
input - message kw delete kw deletion failed=Löschen des Schlagworts fehlgeschlagen.
input - message kw delete kw deletion successful=Löschen des Schlagworts war erfolgreich.
input - message kw delete kw does not exist=Das zu löschende Schlagwort existiert nicht.
input - message kw enter delete kw empty=Bitte geben Sie ein einzutragendes oder zu löschendes Schlagwort ein.
input - message kw enter kw already exists=Schlagwort wurde nicht eingetragen, es existiert bereits.
input - message kw enter kw insertation failed=Die Eintragung des Schlagworts ist fehlgeschlagen.
input - message kw enter kw insertation successful=Die Eintragung des Schlagworts war erfolgreich.
input - message kw rename - kw already existing=Das Schlagworte kann nicht umbenannt werden. Es existiert bereits ein Schlagwort mit dieser Bezeichnung.
input - message kw rename - renaming failed=Umbenennung des Schlagwortes fehlgeschlagen.
input - message kw rename - renaming successful=Umbenennung des Schlagwortes erfolgreich.
input - no keywords assigned to article=Bisher wurden diesem Artikel keine Schlagworte zugewiesen.
output - linkbox headline=Verwandte Themen
Der Dateianhang crosslinking_sd-fe-001.jpg existiert nicht mehr.
crosslinking_sd-fe-001.jpg
crosslinking_sd-fe-001.jpg (54.59 KiB) 17952 mal betrachtet
seamless-design.de
"Geht nicht!" wohnt in der "Will nicht!"-Strasse.

Das Handbuch zur Version 4.10: CONTENIDO für Einsteiger (4.10)

Das Handbuch zur Version 4.9: CONTENIDO für Einsteiger (4.9)
Antworten