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.
- if(class_exists('my-addon_simplepagehead'))
- {
- my-addon_simplepagehead::get_addon_infos( PAGE_ID );
- }
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!
- class news_simplepagehead
- {
- use LEPTON_singleton;
- public string $keywords = 'LEPTON, CMS, Project';
- public static function get_addon_infos ( $iPageId = -1 ):array
- {
- $entries = [];
- if( (defined("POST_ID")) && (is_numeric(POST_ID)))
- {
- $database = LEPTON_database::getInstance();
- $database->execute_query(
- "SELECT title, content_short FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = ".POST_ID,
- true,
- $entries,
- false
- );
- // load droplet engine and process
- LEPTON_handle::include_files ('/modules/droplets/droplets.php');
- foreach($entries as &$temp_entry)
- {
- evalDroplets($temp_entry);
- }
- // return htmlspecial chars to tags and remove tags
- $entries['keywords'] = strip_tags(html_entity_decode(self::getInstance()->keywords,ENT_HTML5));
- $entries['title'] = strip_tags(WEBSITE_TITLE.' - '.html_entity_decode($entries['title'],ENT_HTML5));
- $entries['description'] = strip_tags(html_entity_decode($entries['content_short'],ENT_HTML5));
- // strip quotes and cut length
- $sEntryLength = 180;
- $sLength = $sEntryLength - 40;
- foreach ($entries as $key => &$temp_entry)
- {
- $sValue = str_replace('"', '', $temp_entry);
- if (strlen($sValue) > $sEntryLength)
- {
- if(preg_match('/.{0,'.$sEntryLength.'}(?:[.!?:,])/su', $sValue, $match))
- {
- $sValue = $match[0];
- }
- if (strlen($sValue) > $sEntryLength)
- {
- $pos = strpos($sValue, " ", $sLength);
- if ($pos > 0)
- {
- $sValue = substr($sValue, 0, $pos);
- }
- }
- }
- $temp_entry = $sValue;
- }
- $entries['post_id'] = POST_ID;
- return $entries;
- }
- else
- {
- return $entries;
- }
- }
- }
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.
- {% autoescape false %}
- <!-- start simplepagehead -->
- {{ head.title }}
- <!-- end simplepagehead -->
- {% endautoescape %}
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.