Skip to content

Commit

Permalink
Added 2 more default template variables for the Static Page Plugins
Browse files Browse the repository at this point in the history
Added ISO 8601 date default template variables for created {sp_created} and modified {sp_modfied}.
  • Loading branch information
eSilverStrike committed Nov 26, 2018
1 parent bce96ff commit 6242d1d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions plugins/staticpages/functions.inc
Expand Up @@ -1864,10 +1864,12 @@ function plugin_getListField_staticpages($fieldname, $fieldvalue, $A, $icon_arr)
* @param string $sp_content the content (HTML or PHP source)
* @param int $sp_php flag: 1 = content is PHP source, 0 = is HTML
* @param int $cache_time the max cache time of this page
* @param string $template_id the max cache time of this page
* @param string $template_id Template used for content
* @param string $created Created date of page
* @param string $modified Last modified date of page
* @return string rendered content (HTML)
*/
function SP_render_content($sp_id, $sp_title, $sp_content, $sp_php, $cache_time = 0, $template_id = '')
function SP_render_content($sp_id, $sp_title, $sp_content, $sp_php, $cache_time = 0, $template_id = '', $created = '', $modified = '')
{
global $_SP_CONF, $LANG_STATIC;

Expand Down Expand Up @@ -1931,8 +1933,12 @@ function SP_render_content($sp_id, $sp_title, $sp_content, $sp_php, $cache_time
'page_view' => $retval['sp_content'],
));

// Set Staticpage Title
$sp_template->set_var('sp_title', stripslashes($sp_title));
// Staticpage specfic template variables
// Set Staticpage Title
$sp_template->set_var('sp_title', stripslashes($sp_title));
// ISO 8601 dates for created and modified
$sp_template->set_var('sp_created', date('c', strtotime($created)));
$sp_template->set_var('sp_updated', date('c', strtotime($modified)));

// Add all the staticpage variables as template variables now
foreach ($tag as $key => $value) {
Expand Down
4 changes: 2 additions & 2 deletions plugins/staticpages/services.inc.php
Expand Up @@ -825,7 +825,7 @@ function service_get_staticpages($args, &$output, &$svc_msg)
// WE ASSUME $output doesn't have any confidential fields
// Generate output now (only if not grabbing a template since template is combined with variables first and then generated)
if (!isset($args['template'])) {
$output['sp_content'] = SP_render_content($page, $output['sp_title'], $output['sp_content'], $output['sp_php'], $output['cache_time'], $output['template_id']);
$output['sp_content'] = SP_render_content($page, $output['sp_title'], $output['sp_content'], $output['sp_php'], $output['cache_time'], $output['template_id'], $output['created'], $output['modified']);
}
} else { // an error occurred (page not found, access denied, ...)
/**
Expand Down Expand Up @@ -965,7 +965,7 @@ function service_get_staticpages($args, &$output, &$svc_msg)
//$output_item['category'] = array($output_item['sp_tid']);
$output_item['category'] = TOPIC_getTopicIdsForObject('staticpages', $output_item['sp_id']);
//$output_item['content'] = $output_item['sp_content'];
$output['content'] = SP_render_content($output['sp_id'], $output['sp_title'], $output['sp_content'], $output['sp_php'], $output['cache_time'], $output['template_id']);
$output['content'] = SP_render_content($output['sp_id'], $output['sp_title'], $output['sp_content'], $output['sp_php'], $output['cache_time'], $output['template_id'], $output_item['created'], $output_item['modified']);
$output_item['content_type'] = 'html';

$owner_data = SESS_getUserDataFromId($output_item['owner_id']);
Expand Down

0 comments on commit 6242d1d

Please sign in to comment.