A floating box with an Admin edit link

  Previous article Next article  

A floating box with an Admin edit link

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.2
  Last updated: 25-12-2015
  Comments: 2

A User Defined Tag (UDT) to show an edit page button in the front end of your CMS Made Simple™ website if you are logged in to the CMSMS™ Admin area and have the permission to access that page.

  How to use

Create a UDT named "edit_floater" with the content:

$uid = get_userid(FALSE);
if( !$uid ) return;

$page_id = (int) \cms_utils::get_current_pageid();
if( $page_id < 1 ) return;

// check if we have permission to edit this content page
$out = null;
if( check_permission($uid,'Manage All Content') || check_permission($uid,'Modify Any Page') || check_authorship($uid,$page_id) ) {
  // we can do something
  $mod = \cms_utils::get_module('CMSContentManager');
  if( $mod ) { $url = $mod->create_url('m1_','admin_editcontent','',array('content_id'=>$page_id)); }
  $out = <<<EOT
<div style="position: fixed; z-index: 10000; top: 0; left: 0; background: #fff; padding: 10px; border: 2px solid #f00;">
<a href="{$url}" target="_blank">Edit</a>
</div>
EOT
;
}

// all done
return $out;

Now open the HTML page template and add directly after the <body> tag:

{edit_floater}

When you are logged in the Admin, you will see in the top left corner of the browser an edit link. Click on it will open the page editor in a new browser tab.
Note: This only will open a page, not a News or CGBlog post!


A2 Webhosting CMS Made Simple

Edit

A2 Webhosting CMS Made Simple

  Comments

  Click here to leave a comment






This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)
  « Enter the CAPTCHA code (lower case)

Your IP address will be stored on submit. I reserve the right to change or delete your response without notice!
In case of abuse your IP address will be blocked!


Can I have your attention for a moment?

Did this tutorial help you solving a problem at your (clients) website and it saved you many hours of work? Great!!
Consider buying Rolf a cup of coffee in return! [ Click here ]


  2 Comments

CMS Made Simple 2.2.2 - Tutorials, tips and tricks - CMSMS 2.2.2

A floating box with an Admin edit link

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.2
  Last updated: 25-12-2015
  Comments: 2

A2 Webhosting CMS Made Simple