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

As Couch CMS don't offer the possibility for visitors to create their own accounts and then to login and access some restricted areas, (in Couch only the admin can create user accounts), I want to implement a login script for this purpose, but faceing the following situation.
I have the script and it wolud be easy to implement it on a single Login page (login.php). But what I'm trying to do is to place the login facility on each page header, when the user clicks on Login a dropdown will be displayed, here the user enter his login credentials and get access to a Dashboard. So I have the dropdown with the login form, I have the login script also, but having the following php code in heather for displaying login error messeges:
<?php
/******************** ERRORMESSAGES
*****This code is to show error messages **************/
if(!empty($err)) {
echo "<div class=\"msg\">";
foreach ($err as $e) {
echo "$e <br>";
}
echo "</div>";
}
/******************************* END *************/
?>

I don't know how to place all this header section into a snippet for embed it in every page of the website.
If I put it as it is, it messes all may design, it totally brokes the page.
Is there a way of dealing this situation?

Thank you,
Attila
Embedded snippets cannot execute raw PHP.
We need to use the cms:php Couch tag instead.
Please modify the code you pasted into the following before using it as snippet -
Code: Select all
<cms:php>
global $err;

/******************** ERRORMESSAGES
*****This code is to show error messages **************/
if(!empty($err)) {
echo "<div class=\"msg\">";
foreach ($err as $e) {
echo "$e <br>";
}
echo "</div>";
}
/******************************* END *************/
</cms:php>

As you can see, the conversion is trivial - we just substitute the <?php .. ?> with <cms:php>..</cms:php> and define any referenced valriables (e.g. the $err in our case) as being global.

Hope this helps.

P.S. I'd be interested to know how the user script works out for you. Do share the solution here if it works out well. Thanks.
Hi KK,

It works like a charm! You saved me once again :) Thank you for the great support you are offering for this fantastic CMS!
Regarding the user script: as far as I can see, it looks good, probably the few next days I'll manage to implement it completely (signup, login, logout, Couch managed user pages, and so on). I'll definitely share my solution with the other members of this community.

Attila
KK wrote: P.S. I'd be interested to know how the user script works out for you. Do share the solution here if it works out well. Thanks.


User script is working fine with Couch, there are no problems at all :) As you could see I'm a beginner in php so I used a free php login script called php login v2.3, which is very easy to integrate in couch. I just took from it all the code and integrated it into my clonable and nested couch template(s), so I have full access to post any information I want, the menu is generated automatically, is just great!
The full features of login script are available here: http://www.php-login-script.com/
If someone need more information on this or help implementing the login script on his site just tell me and I will help him/her out.

Attila
Hi Attila,

Thank you very much for letting us know about the fine script.
Hopefully the coming version of Couch will provide all these functionalities (and more) natively.
5 posts Page 1 of 1
cron