【问题标题】:Joomla 3 Hide Content from specific pageJoomla 3隐藏特定页面的内容
【发布时间】:2016-08-27 10:48:53
【问题描述】:

我希望在所有页面上出现的某些页面上隐藏一个 div。我使用了一些 php 和 css 为每个页面分配了唯一的代码,但我无法获得正确的 css 来隐藏或删除这些页面中的 div。

 .pageid111 .logo{
   display: none;
  }

是我正在尝试使用的。希望有任何帮助

【问题讨论】:

  • “来自特定页面”是什么意思?您是否要在主页上隐藏徽标?
  • 嗯,是的。我在主页上有徽标,但不希望它出现在关于我们的页面上
  • 你的 HTML 是什么样的?具体来说,您的 PHP 为每个页面分配唯一代码的 HTML 行是什么样的?将主页类放在主页 html 中的 body 元素上可能会更容易。
  • 实时网站副本的链接可能会引出一些更明确的答案。

标签: php html css joomla joomla3.0


【解决方案1】:

您可以创建一个模块并在任何需要的地方显示它,而不是直接在所有文件中调用 logo。您必须更改模板文件中的一些代码。我将给出一个示例,以便您可以为自己的模板进行操作。

如果您看到 Joomla 附带的默认模板 protostar。它有一个名为 index.php 的文件。 $logo 在第 67-78 行定义为

// Logo file or site title param
if ($this->params->get('logoFile'))
{
    $logo = '<img src="' . JUri::root() . $this->params->get('logoFile') . '" alt="' . $sitename . '" />';
}
elseif ($this->params->get('sitetitle'))
{
    $logo = '<span class="site-title" title="' . $sitename . '">' . htmlspecialchars($this->params->get('sitetitle')) . '</span>';
}
else
{
    $logo = '<span class="site-title" title="' . $sitename . '">' . $sitename . '</span>';
}

你可以把它注释掉。

接下来在第 140 行附近的同一个文件中,您将找到此代码

<?php echo $logo; ?>

此代码正在调用徽标文件。只需将此代码替换为

<jdoc:include type="modules" name="logo" style="xhtml" />

您刚刚添加了一个名为 logo 的新模块位置。

在您将此位置添加到 templateDetails.xml 文件中之前,这不会反映出来

如果你打开那个文件,你会发现这些行

<positions>
        <position>banner</position>
        <position>debug</position>
        <position>position-0</position>
        <position>position-1</position>
        .............
</positions>

为其添加徽标位置

<positions>
        <position>banner</position>
        <position>debug</position>
        <position>logo</position>
        <position>position-0</position>
        <position>position-1</position>
        .............
</positions>

因此,您现在有一个额外的模块位置来代替硬编码的徽标图像。您可以将任何图像模块放在那里,也可以只创建一个 html 模块。

【讨论】:

    【解决方案2】:

    一种解决方案可以是使用 joomla 框架检测主页 https://docs.joomla.org/How_to_determine_if_the_user_is_viewing_the_front_page

    通过相同的 getMenu() 方法,您可以将代码概括为其他菜单项 Joomla 3.1 - Get active menu item url

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-29
      • 2017-11-18
      • 1970-01-01
      • 2014-08-17
      • 2016-02-12
      • 1970-01-01
      • 2016-12-26
      相关资源
      最近更新 更多