Forum for discussing general topics related to Couch.
5 posts Page 1 of 1
Hi all
I found this CouchCMS last night and I'm really enjoying it so far. I've come from a background of large CMSs and they are just too much for a basic site.
I've been looking on and off for years for a decent CMS with client friendly frontend editing capabilities. And this is definitely it!

I've set up CouchCMS and the sample one page 'miniport' template. It's working perfectly on my shared host, out of the box, which is rare.

I have set up myself as Super Admin. I have also set up an Authenticated User account to be used by an editor/client.

What I really want is the editor/client (Authenticated User) to be redirected to the homepage after login. I'm hoping they can just use the frontend editing without needing to see the backend.

Is this possible?

Simon66
Hello and welcome, Simon :)
I'm glad you liked Couch.

You mentioned -
I have set up myself as Super Admin. I have also set up an Authenticated User account to be used by an editor/client.
I think you meant the plain 'Admin' account for the editor ( Usually this is the site-owner). Only super-admin and admin are allowed access to the admin-panel (and hence, by extension, to front-end editing).

Anyway, replying to your query -
What I really want is the editor/client (Authenticated User) to be redirected to the homepage after login. I'm hoping they can just use the frontend editing without needing to see the backend.
As I said, the second (i.e. admin) account is meant for the site-owner so usually there is no need to hide the admin-panel from him. Therefore, out-of-the-box, Couch does not provide any method to do so.

However, if you really must do it we can use a little work-around. Let me explain.
We build upon two behaviors of Couch -
1. When you login into the admin-panel, Couch always displays the listing of the very first template (whatever that might be).

2. We can use a custom admin-screen (essentially just an ordinary template) for any template.
(you might want to see the docs at http://www.couchcms.com/docs/concepts/d ... forms.html if you need more info about custom admin screens. Scroll down and you'll get a section by this name).

So what we'll do is, create a dummy clonable Couch template (say named 'redirect.php') and associate it with a custom admin screen. In the custom screen we'll put our logic of checking if the logged-in user is a simple admin and redirect her to the site if so.

We'll make our dummy template the very first template listed in the sidebar so whenever someone logs in Couch tries to display the custom screen. The code in the custom screen then does the redirect.

Don't worry it will be easier to actually do than to explain. Just follow the instructions below.

1. We'll begin by creating a dummy template named redirect.php.
Put just the following into it -
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template clonable='1' order='-10'>

</cms:template>
<?php COUCH::invoke(); ?>

Register it by visiting it as super-admin.
Coming back to the admin-panel you'll find that it is listed as the very first template in the sidebar (the negative value we used with the 'order' parameter in the template's definition does this).

2. Associate a custom admin screen with this template by adding the following line of code to your 'couch/addons/kfunctions.php' file (you might have to rename 'kfunctions.example.php' to 'kfunctions.php') -
Code: Select all
$FUNCS->register_admin_listview( 'redirect.php', 'my_redirect.html' ); 

Now when you'll access the admin-panel, it should show you an error message like
ERROR: Unable to get contents from custom list_view snippets/my_redirect.html

That is because it is now trying to read 'my_redirect.html' from your snippets folder to show it here but we have not placed any such file. So let us do that -

3. Create a file named 'my_redirect.html' and place it in your snippets folder (by default it is 'couch/snippets'). Put the following code into it -
Code: Select all
<cms:if k_user_access_level lt '10' >
    <cms:redirect k_site_link />
</cms:if>
As you can see, the code above simply checks if the user is not the super-admin (i.e. will be admin) and redirects her to the main site.

Test it out by trying to log as a normal admin.

Hope it helps. Do let us know.
I'm hoping they can just use the frontend editing without needing to see the backend.

Not necessarily better or worse than KK's idea, but here's another way of approaching this.

You can place a login link on the front end of the site. When the administrator clicks on the link, they will see the login page. After they successfully log in they will be redirected back to the page they came from. When I've done this, I put the login link on a logo image in the footer to hide it from the casual visitor. But the site administrator knows this is the button to push in order to begin editing.

This doesn't actively prevent the admin from gaining access to the backend in the same way that KK's solution does, but they can remain ignorant of the admin panel and simply edit on the front end using inline editing.

On a multi-page site, this has the advantage of allowing a user to login and begin editing right where they are on the site.

Code: Select all
<cms:if k_logged_out >
    <a href="<cms:show k_login_link />" rel="nofollow"><img src="my-logo.jpg" alt="" /></a>
<cms:else />
    <a href="<cms:show k_logout_link />">Logout<br/></a><img src="my-logo.jpg" alt="" />
</cms:if>

Notice the rel="nofollow" attribute that keeps your login page from being indexed.

Edited a mistake in the code snippet.
@Tim
Short and sweet :)
Thanks for the replies guys!

All this help is much appreciated and so different from the apathy of many other CMS forums.

As soon as I'm up to speed with Couch I hope I can be as much help in return.

Simon66

P.S. The documentation is mind-bogglingly good. Another rare treat.
5 posts Page 1 of 1
cron