Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
Hi there,

Could not finde anything in the search.

is there a tag like admin_link which sends the user to the Backend of a template but instead of editing an existing page adds a new one?

thanks in advance :)
Hi,

No such tag in the core but it should be easy to create a custom one.

Please paste the following in your 'couch/addons/kfunctions.php' file (if the file does not exist, rename the 'kfunctions.example.php' to it) -
Code: Select all
// TAG: <cms:admin_create_link />
// outputs 'create page' admin link
$FUNCS->register_tag( 'admin_create_link',
    function( $params, $node ){
        global $FUNCS, $CTX, $AUTH;

        if( count($node->children) ) {die("ERROR: Tag \"".$node->name."\" is a self closing tag");}

        // if current user is not an administrator or template is non-clonable, return.
        if( $AUTH->user->access_level < K_ACCESS_LEVEL_ADMIN || $CTX->get('k_is_list_page')) return;

        $nonce = $FUNCS->create_nonce( 'create_page_'.$CTX->get('k_template_id') );
        $link = K_ADMIN_URL . K_ADMIN_PAGE . '?o='. $CTX->get('k_template_name') .'&q=create/'. $nonce;

        return $link;
});

And now you should have a new tag named <cms:admin_create_link /> ready for use e.g.
Code: Select all
<a href="<cms:admin_create_link />">Create a new page</a>

Hope this helps.
Thank you very much, this helps a lot :)
3 posts Page 1 of 1