feel free to keep it strictly simple...

Connect with SimplePageHead

Starting with L* 7  a new release of addon simplepagehead is available with a new strategy:

addon authors now have the chance to connect with simplepagehead to get the values displayed you want.

If you want to connect your addon with new simplepagehead, please follow these steps:

Connect with simplepagehead: step 1

First use a hook in your addon after simplepagehead is installed. Use your own addon class or the view.php to set the hook.

  1. if(class_exists('my-addon_simplepagehead'))
  2. {
  3. my-addon_simplepagehead::get_addon_infos( PAGE_ID );
  4. }
last edit: 29. Apr 2023 CEST 16:11:28

Connect with simplepagehead: step 2

Create a class in your addon named my-addon_simplepagehead.php in your classes folder. The is the file, where you collect all the data that will be send to simplepagehead. For an example please have a look at the implemented news module!

  1. class news_simplepagehead
  2. {
  3. use LEPTON_singleton;
  4. public string $keywords = 'LEPTON, CMS, Project';
  5. public static function get_addon_infos ( $iPageId = -1 ):array
  6. {
  7. $entries = [];
  8. if( (defined("POST_ID")) && (is_numeric(POST_ID)))
  9. {
  10. $database = LEPTON_database::getInstance();
  11. $database->execute_query(
  12. "SELECT title, content_short FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = ".POST_ID,
  13. true,
  14. $entries,
  15. false
  16. );
  17. // load droplet engine and process
  18. LEPTON_handle::include_files ('/modules/droplets/droplets.php');
  19. foreach($entries as &$temp_entry)
  20. {
  21. evalDroplets($temp_entry);
  22. }
  23. // return htmlspecial chars to tags and remove tags
  24. $entries['keywords'] = strip_tags(html_entity_decode(self::getInstance()->keywords,ENT_HTML5));
  25. $entries['title'] = strip_tags(WEBSITE_TITLE.' - '.html_entity_decode($entries['title'],ENT_HTML5));
  26. $entries['description'] = strip_tags(html_entity_decode($entries['content_short'],ENT_HTML5));
  27. // strip quotes and cut length
  28. $sEntryLength = 180;
  29. $sLength = $sEntryLength - 40;
  30. foreach ($entries as $key => &$temp_entry)
  31. {
  32. $sValue = str_replace('"', '', $temp_entry);
  33. if (strlen($sValue) > $sEntryLength)
  34. {
  35. if(preg_match('/.{0,'.$sEntryLength.'}(?:[.!?:,])/su', $sValue, $match))
  36. {
  37. $sValue = $match[0];
  38. }
  39. if (strlen($sValue) > $sEntryLength)
  40. {
  41. $pos = strpos($sValue, " ", $sLength);
  42. if ($pos > 0)
  43. {
  44. $sValue = substr($sValue, 0, $pos);
  45. }
  46. }
  47. }
  48. $temp_entry = $sValue;
  49. }
  50. $entries['post_id'] = POST_ID;
  51. return $entries;
  52. }
  53. else
  54. {
  55. return $entries;
  56. }
  57. }
  58. }
last edit: 17. Aug 2023 CEST 11:05:33

Connect with simplepagehead: step 3

If you want to create our own simplepagehead output copy the standard output file in simplepagehead/templates/output.lte and rename it to output_custom.lte.

  1. {% autoescape false %}
  2. <!-- start simplepagehead -->
  3. <meta name='viewport' content='width=device-width,initial-scale=1' />
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <meta name="language" content="{{ language }}" />
  6. <title>{{ head.title }}</title>
  7. <meta name="description" content="{{ head.description }}" />
  8. <meta name="keywords" content="{{ head.keywords }}" />
  9. <meta name="generator" content="CMS:LEPTON; https://lepton-cms.org" />
  10. <link rel="shortcut icon" href="{{ LEPTON_URL }}/templates/{{ DEFAULT_TEMPLATE }}/img/favicon.ico" />
  11. <!-- end simplepagehead -->
  12. {% endautoescape %}
last edit: 29. Apr 2023 CEST 16:19:12

You can follow the implementation of the news module to create your own content.

In addition please keep attention on the readme file of simplepagehead.

If you have some difficulties or further questions please use the forum.