|
Cookbook /
FoxAuthUserCommentBoxSummary: Posting comments for logged in users only, using Fox
Version: 2011-12-23
Prerequisites: fox.php, foxdelete.php, authuser.php
Status:
Maintainer: HansB
Discussion: FoxAuthUserCommentBox-Talk?
Questions answered by this recipeHow to add comments for logged in users only, using Fox DescriptionThis is an example for setting up a comment form for posting comments for logged in users only, using Fox and AuthUser InstallationAdd following to config.php, $FoxPagePermissions should be set for the group or page in which comments should be posted (in this example it is for all pages in group Test): include_once("scripts/authuser.php");
if ($AuthId) {
$Author = $AuthId;
setcookie('author',$Author,0,'/');
}
include_once("$FarmD/scripts/author.php");
Conditions['authuser'] = '\$GLOBALS["AuthId"]==\$condparm';
$FoxPagePermissions['Test.*'] = 'add,delete';
include_once("$FarmD/cookbook/fox/fox.php");
include_once("$FarmD/cookbook/fox/foxdelete.php");
ConfigurationPage Site.AuthUser should be configured with user ids and their passwords, or users and passwords set up in a different way. Add to Site.FoxForms this Fox comment form code:
[[#commentform]]
(:foxmessage:)
(:fox cbox put=below mark=!!Comments template=Site.FoxTemplates#comment:)
Subject: (:input text heading size=60:)
'''Your Comment:'''
(:input textarea comment cols=60 rows=6:)
(:input hidden author value='{$AuthId}' :) (:input submit post "Add Comment":)
(:foxend cbox:)
[[#commentformend]]
Add to Site.FoxTemplates this comment template:
[[#comment]]
#foxbegin#
(:div1 class=messagehead:)
>>rfloat<<
[-{$$(date d.m.Y - H:i)}-] (:if expr auth admin or authuser {$$author}:){[foxdelrange]}(:if:)
>><<
!!!!!{$$author}
(:div1end:)
>>messageitem<<
'''{$$heading}'''
>>messageitem<<
{$$comment}
>><<
#foxend#
[[#commentend]]
Add to each page or the GroupHeader (or GroupFooter) this markup for the comment form:
(:if authid:)Logged in as '''{$AuthId}''' - [-[[{*$FullName}?action=logout| (log out)]]-]
(:foxform Site.FoxForms#commentform :)
(:else:)Please [[{*$FullName}?action=login|log in]] to add comment!
(:ifend:)
!!Comments
Add to pub/css/local.css some styles (taken from CommentBoxPlus styles css):
/* styling of commentbox entries */
#message { clear:both; }
.messagehead, .journalhead {
margin:1em 0 0 0;
padding:0 0 0 3px;
border:1px solid #ccc;
}
.messageitem, .journalitem {
margin:0;
padding:3px;
border-left:1px solid #ccc;
border-right:1px solid #ccc;
border-bottom:1px solid #ccc;
}
.messagehead { background:#f0f0f0; }
/*use the following if message head should be same as message item */
/* .messagehead { background:#eef; border-bottom:none; } */
.messageitem { background:#f7f7f7; }
Notes
the user.
for the admin (logged in as admin).
UsageChange log / Release notes
See alsoContributorsCommentsSee discussion at FoxAuthUserCommentBox-Talk? User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |