diff --git a/bl-kernel/admin/views/editor.php b/bl-kernel/admin/views/editor.php index a231ca69..5ad58fbe 100644 --- a/bl-kernel/admin/views/editor.php +++ b/bl-kernel/admin/views/editor.php @@ -77,6 +77,10 @@ _pageKey = response.data.key; // Set friendly URL with the key //$('#friendlyURL').val(response.data.key); + $('#btnPreview').attr('data-key', response.data.key); + if (response.data.preview) { + $('#btnPreview').attr('data-preview', response.data.preview); + } } else { logs('An error occurred while trying to save the current page.'); showAlertError(response.message); @@ -228,6 +232,12 @@ openModal('type'); }); + $('#btnPreview').click(function() { + if ($(this).attr('data-key') && $(this).attr('data-preview')) { + window.open(''+$(this).attr('data-key')+'?preview='+$(this).attr('data-preview')); + } + }); + $('#category').on("change", function() { enableBtnSave(); }); diff --git a/bl-plugins/api/plugin.php b/bl-plugins/api/plugin.php index f714efce..39b062e1 100644 --- a/bl-plugins/api/plugin.php +++ b/bl-plugins/api/plugin.php @@ -548,11 +548,14 @@ class pluginAPI extends Plugin { 'message'=>'Error trying to edit the page.' ); } + + $page = new Page($newKey); + $preview = md5($page->uuid()); return array( 'status'=>'0', 'message'=>'Page edited.', - 'data'=>array('key'=>$newKey) + 'data'=>array('key'=>$newKey, 'preview'=>$preview) ); } @@ -1095,4 +1098,4 @@ class pluginAPI extends Plugin { 'message'=>'An error occurred while trying to configure the plugin.' ); } -} \ No newline at end of file +}