Aufhänger für dieses Modul war folgendes Thema: http://forum.contenido.org/viewtopic.php?f=90&t=36765. Gewünscht war die Möglichkeit, dem Seitenbesucher die letzten x aufgerufenen Webartikel als Linkliste anzuzeigen. Genutzt wird hierfür der localstorage des verwendeten Webbrowsers. Die Anzahl der zuletzt aufgerufenen Webartikel kann über die Variable $amount_of_entries am Anfang der Modul-Ausgabe festgelegt werden. Für den Linktext wird die Headline des jeweiligen Webartikels verwendet. Die Ausgabe selbst ist "plain-HTML", so dass sich jeder selbst bei der Optik austoben kann...
Modul-Ausgabe
Code: Alles auswählen
<?php
/***********************************************
* article_history_sd output
*
* Author      :     seamless-design Markus Hübner
* Copyright   :     seamless-design Markus Hübner
* Created     :     2016-03-26
************************************************/
/*
important: this module uses information of array $breadcrumb, which is generated by contenido standard module 'head_title'. if you do not implement this module first in your template, 'article_history_sd' does not work. you'll have to determine necessary data right here. to do that, you'll have to turn the following comment-section into executed code by removing comment markers
known issue within contenido 4.9.9 and lower:
if you use standard-module "navigation_breadcrumb", "article_history_sd" won't work. Reason: both modules, "head_title" and "navigation_breadcrumb" use $breadcrumb as an array. If you execute "navigation_breadcrumb", contents of $breadcrumb are replaced and not suitable for using within "article_history_sd". Solution: Rename $breadcrumb within "navigation_breadcrumb" (e.g. $breadcrumb_navigation) and all works fine.
*/
/*
$breadcrumb = array();
// get category path
$helper = cCategoryHelper::getInstance();
foreach ($helper->getCategoryPath(cRegistry::getCategoryId(), 1) as $categoryLang) {
    $breadcrumb[] = $categoryLang->get('name');
}
// load current article information
$article = new cApiArticleLanguage();
$article->loadByArticleAndLanguageId(cRegistry::getArticleId(), cRegistry::getLanguageId());
$headline = strip_tags($article->getContent('CMS_HTMLHEAD', 1));
// append headline of article if existing
if ($headline != '') {
    $breadcrumb[] = $headline;
}
if ($headline === '') {
    $breadcrumb[] = mi18n("STARTPAGE");
}
*/
$amount_of_entries=5;
$uri=$_SERVER['REQUEST_URI'];
$linktext=end($breadcrumb);
?>
<script type="text/javascript">
var var_amount_of_entries=<?php echo $amount_of_entries;?>*2;
if(typeof(Storage)!=="undefined")
  {
  var var_current_localstorage=localStorage.getItem("article_history_sd");
if(var_current_localstorage!=null)
  {
  var array_current_localstorage=var_current_localstorage.split("+++");
  document.write('<hr>');
  var_current_localstorage="";
  for (i=1; i<=var_amount_of_entries; i++)
    {
   if(array_current_localstorage[i]!=undefined)
     {
     if(var_current_localstorage.indexOf(array_current_localstorage[i])<0) // if result is <0, no index is found what means: no similar entry given and article can be listed
       {
       document.write('<a href="'+array_current_localstorage[i]);
       var_current_localstorage+='+++'+array_current_localstorage[i];
       i++;
       document.write('" title="'+array_current_localstorage[i]+'">'+array_current_localstorage[i]+'</a><br/>');
       var_current_localstorage+='+++'+array_current_localstorage[i];
       }
       else i++;
     }
     else i=var_amount_of_entries;
    }
  document.write('<hr>');
  }
  else var_current_localstorage="";
var_new_localstorage="<?php echo '+++'.$uri.'+++'.$linktext; ?>"+var_current_localstorage;
localStorage.setItem("article_history_sd", var_new_localstorage);
  }
</script>