在 1.6 之前的 Joomla 中,我可以将菜单项设置为公开,以及它的内容:例如一篇注册的文章.
In Joomla prior to 1.6 i could set a menu-item to public, and its contents: an article for example to registered.
这会导致人们在未登录时可以在菜单中看到文章链接,但只要点击它就会获得登录组件.之后他们看到了这篇文章.
This lead to a situation where people could see the link to an article in the menu when not logged in, but got a login component whenever they clicked it. And after that they saw the article.
在 1.7 中,这些相同的操作会导致当我单击链接时组件屏幕保持空白的情况.
In 1.7 these same actions lead to a situation where when I click the link the component screen just stays empty.
当前端用户没有以足够的权限登录时,如何让注册的文章显示登录屏幕? 以前很容易,但我似乎无法让它工作现在.
How do I get registered articles to show a login screen when the front end user is not logged in with sufficient rights? It was soo easy before and I can't seem to get it to work now.
我要回答我自己的问题,因为我相信将来人们会需要这个,而我的解决方案只涉及一些额外代码的规则,然后你就可以将每篇文章等...设置为已注册,当用户未登录时,您将看到一个登录字段.
Im gonna answer my own question, because Im sure people will need this in the future, and my solution only involves a few rules of extra code and then you can set every article etc... to Registered and you'll see a login field when a user is not logged in.
在你的模板 index.php 中,将它放在靠近顶部的位置,它可以获得你文章的访问级别.
In your templates index.php place this near the top, it gets your article's access level.
$article =& JTable::getInstance("content");
$article->load(JRequest::getVar('id'));
$cAccLevel = $article->get("access");
然后在您的组件上方添加一个模块位置,并且仅在您需要的访问级别> 1 时才显示它
Then add a module position above your component, and only show it when your needed access level is > 1
<?php if($cAccLevel > 1): ?>
<jdoc:include type="modules" name="LOGIN_MODULE_POSITION" />
<?php endif; ?>
然后在模块管理器中将登录模块添加到 LOGIN_MODULE_POSITION.
Then add a login module in your module manager to LOGIN_MODULE_POSITION.
瞧...不需要路由等等...一切都是开箱即用的,我选择像这样设置注销框和操作字段的样式:
Voila... no routing needed etc... everything works out of the box, I chose to style away the logout box and action field like this:
.logout-button,
.actions{
display:none;
}
祝你好运!
这篇关于仅向注册用户显示 joomla 文章,如果未登录则显示登录屏幕是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!