Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2013-06-20 08:14:15
- lara
- New Member
- Registered: 2013-06-20
- Posts: 1
Password protect certain categories
I have three categories (news,archive,senior-pathways) within my news section and I want all articles password protected except for one category(senior-pathways).
Is this possible or for security reasons, can you not segment password protecting?
I have tried a lot of things but nothing seems to work. The most logical method I can think of is putting an ‘<txp:if_category name=“news,archive”>’ around the ‘<txp:password_protect login=“xxx” pass=“yyy” />’ statement, but this makes it so nothing is password protected. In other methods, everything is password protected.
Please see my code below, I would love some help on this one!
<txp:if_individual_article>
<txp:if_category name=“news,archive”> <txp:password_protect login=“xxx” pass=“yyy” /> </txp:if_category> <txp:article form=“article_full” limit=“1” sort=“Posted asc” status=“sticky”/> <txp:article form=“article_full” limit=“1” sort=“Posted asc” status=“live”/><txp:else/>
<txp:article_custom form=“article_excerpt” limit=“1” pgonly=“0” section=“news” sort=“Posted desc” status=“sticky”/> <txp:soo_if_frontpage section=“news”> <txp:article_custom form=“article_excerpt” limit=“99” pgonly=“0” section=“news” sort=“Posted desc” category=“news,senior-pathways” expired=“0” /> <txp:else /> <txp:article_custom form=“article_excerpt” limit=“99” pgonly=“0” section=“news” sort=“Posted desc” category=’<txp:category type=“article”/>’ expired=“1” /> </txp:soo_if_frontpage></txp:if_individual_article>
Offline
Re: Password protect certain categories
lara wrote:
I have three categories (news,archive,senior-pathways) within my news section and I want all articles password protected except for one category(senior-pathways).
Is this possible or for security reasons, can you not segment password protecting?
I have tried a lot of things but nothing seems to work. The most logical method I can think of is putting an
<txp:if_category name="news,archive">
around the<txp:password_protect login="xxx" pass="yyy" />
statement, but this makes it so nothing is password protected. In other methods, everything is password protected.Please see my code below, I would love some help on this one!
<txp:if_individual_article>
<txp:if_category name="news,archive">
<txp:password_protect login="xxx" pass="yyy" />
</txp:if_category>
<txp:article form="article_full" limit="1" sort="Posted asc" status="sticky"/>
<txp:article form="article_full" limit="1" sort="Posted asc" status="live"/>
<txp:else/>
<txp:article_custom form="article_excerpt" limit="1" pgonly="0" section="news" sort="Posted desc" status="sticky"/>
<txp:soo_if_frontpage section="news">
<txp:article_custom form="article_excerpt" limit="99" pgonly="0" section="news" sort="Posted desc" category="news,senior-pathways" expired="0" />
<txp:else />
<txp:article_custom form="article_excerpt" limit="99" pgonly="0" section="news" sort="Posted desc" category='<txp:category type="article"/>' expired="1" />
</txp:soo_if_frontpage>
</txp:if_individual_article>
I think you need to use a plugin to do this. I’ve used ign_password_protect on a site to provide a private members-only section and it works very well with Txp 4.5.4. You could also try looking at cbe_frontauth.
Try using this code:
<txp:if_individual_article>
<txp:if_category name="news,archive">
<txp:ign_if_logged_in>
<txp:article form="article_full" limit="1" sort="Posted asc" status="sticky"/>
<txp:article form="article_full" limit="1" sort="Posted asc" status="live"/>
<txp:else />
<p>Please log in to view this article.</p>
<txp:ign_show_login />
</txp:ign_if_logged_in>
<txp:else />
<txp:article form="article_full" limit="1" sort="Posted asc" status="sticky"/>
<txp:article form="article_full" limit="1" sort="Posted asc" status="live"/>
</txp:if_category>
<txp:else/>
<txp:article_custom form="article_excerpt" limit="1" pgonly="0" section="news" sort="Posted desc" status="sticky"/>
<txp:soo_if_frontpage section="news">
<txp:article_custom form="article_excerpt" limit="99" pgonly="0" section="news" sort="Posted desc" category="news,senior-pathways" expired="0" />
<txp:else />
<txp:article_custom form="article_excerpt" limit="99" pgonly="0" section="news" sort="Posted desc" category='<txp:category type="article"/>' expired="1" />
</txp:soo_if_frontpage>
</txp:if_individual_article>
Offline
Re: Password protect certain categories
Try to replace <txp:if_category />
by <txp:if_article_category />
, putting this in your article form:
<txp:if_article_category name="news,archive">
<txp:password_protect login="xxx" pass="yyy" />
</txp:if_article_category>
Offline
Pages: 1