简体   繁体   English

非登录用户的Joomla插件或模块显示

[英]Joomla plugin or module display for non logged-in user

How would I display a module or use a plugin in Joomla to only load if a user is not logged in? 如果用户未登录,如何在Joomla中显示模块或使用插件加载? I understand how to do the opposite by only displaying modules to users that are logged in, but not if they are not. 我了解如何通过仅向已登录的用户显示模块而不是向未显示的用户显示模块来实现相反的操作。

Here is an example, 这是一个例子

I have some html and flash that I want to display in modules to advertise the benefits of joining a club. 我想在模块中显示一些HTML和Flash,以宣传加入俱乐部的好处。 This content will be displayed on the homepage. 此内容将显示在主页上。 However, if a user is logged in, I do not want him to see this content. 但是,如果用户已登录,则我不希望他看到此内容。

Have you tried including the following in your code? 您是否尝试过在代码中包含以下内容?

$user = &JFactory::getUser();
if ($user->guest) {
  // The code to display to the guests here...
} else {
  return;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM