What if you want to show a teaser of the document?
Here is how:
Create the resource, and do not set the page permission.
Instead, set it to a template which output the resource content by a snippet.
Example template:
[[!out.content? &content=`[[*content]]` &guest=`[[*introtext:empty=`[[*content:ellipsis=`600`:striptags]]`]]` &role=`myrole`]]
-------------
This example above will pass in summary of 600 charactors text for guest while output the full content on Logged in with role specified
-------------
Example snippet:
-------------
$aGroups = $modx->getUserDocGroups(true);
if ($aGroups != null) {
foreach($aGroups as $sGroup) {
if (strtolower(trim($sGroup)) == strtolower(trim($role)) ) {
return $content;
}
}
}
return $guest;
Hope it helps ;)
Cheers~
No comments:
Post a Comment