So...
1. Lets make a UDT, called "passprotect"
Code: Select all
// Params:
// passprot - password
// contentprot - protected content, smarty tag, etc.
session_start();
$passprot = $params['passprot']; //read password from field definition
$pass = $_POST[pass];
if ($pass)
{
if ($pass==$passprot)
{
$_SESSION[passprot] = $passprot;
echo $params['contentprot'];
}
else
{
echo 'Wrong password.';
}
}
else
{
echo '
<form method=post>
Enter the password: <INPUT TYPE="PASSWORD" NAME="pass" VALUE="'.$pass.'">
<INPUT TYPE="SUBMIT" VALUE="OK">
</FORM>
';
}
$action = $_GET[action];
if ($action=="logout")
{
session_destroy(); // auto log out
}
First field (password protect option on/off):
Code: Select all
*Name: Checkpass
*Type: Checkbox
*Public (yes)
Code: Select all
*Name: Articlepass
*Type: Text field/area (Normal field, no wysiwyg)
*Max. length: 255
*Public (yes)
Find something like this:
Code: Select all
{else if $entry->content}
<div class="NewsSummaryContent">
{eval var=$entry->content}
</div>
{/if}
Code: Select all
{else if $entry->content}
<div class="NewsSummaryContent">
{if $entry->checkpass==1}
Password protected article {$entry->morelink}
{else}
{eval var=$entry->content}
{/if}
</div>
{/if}
Second IF - but if the content is protected (the checkbox called "Checkpass" is selected in this article) - show me "more link" only, and hide the content.
4. Almost done. Lets go to our detail article template:
Find something like this:
Code: Select all
<div id="NewsPostDetailContent">
{eval var=$entry->content}
</div>
Code: Select all
<div id="NewsPostDetailContent">
{if $entry->checkpass==1}
{passprotect passprot==$entry->articlepass contentprot==$entry->content }
{else}
{eval var=$entry->content}
Make a new article and fill the password field (Articlepass) and check the checkbox (Checkpass) to activate it.
Tell me if something goes wrong (maybe I've done some typo mistake etc.)
All best.