Joomla - 一个模板文件中的多种布局

发布于 2024-12-08 05:25:17 字数 844 浏览 0 评论 0原文

我开始在 Joomla 1.6 中建立一个网站。该网站将主要有两种布局。一个用于主页,另一个用于所有其他子页面。

问题是:我想将这两种布局放在一个模板(或文件夹)中。

我以前见过通过使用带有 JURI:current() 函数的条件语句来完成此操作,但由于某些奇怪的原因,它对我来说无法正常工作。

这是一些基本的伪代码来指示我正在尝试做什么...

<?php 

$HomePagePath = 'Homepage URL here...';
echo JURI::current(); // Just to test what the current output is going to be.
?>

<?php if(JURI::current() == $HomePagePath ): ?>

Template for homepage here

<? else; ?>

Template for sub-pages here

<? endif; ?>

当我测试使用此代码构建的内容时,它无法正常工作。我已多次确保当前 JURI 的输出与浏览器中的当前 URL 相匹配。它向我显示子页面内容而不是主页内容...我不确定是什么原因造成的:/ ...

我目前正在运行这个网站,背后没有真正的域。我暂时使用 GoDaddy 预览 DNS 功能...该功能基本上为我提供了一个临时域,直到我指向合适的域为止。我不知道这是否与当前 JURI 无法正确解析有关?这是我能想到的唯一会导致这个问题的事情......

我想我的下一个问题是......除了 current() 函数之外,你知道另一种方法可以完成我想要做的事情吗?

谢谢!

克里斯

I am starting to build a website in Joomla 1.6. The website is going to primarily have two layouts. One for the homepage and the other is for all the other sub-pages.

The catch: I am wanting to put both the layouts in one template (or folder).

I have seen this done before by using a conditional statement with the JURI:current() function, but for some odd reason, it is not working properly for me.

Here is some basic psuedocode to indicate what I am trying to do...

<?php 

$HomePagePath = 'Homepage URL here...';
echo JURI::current(); // Just to test what the current output is going to be.
?>

<?php if(JURI::current() == $HomePagePath ): ?>

Template for homepage here

<? else; ?>

Template for sub-pages here

<? endif; ?>

When I test what I am building with this code, it is not working properly. I have ensured several times that the output from the current JURI matches the current URL in the browser. It is showing me the sub-page content rather than the homepage content... I am not sure what is causing this :/ ...

I am currently running this website without a real domain behind it. I am using the GoDaddy Preview DNS feature for the time being... This feature basically gives me a temporary domain until I point the appropriate one. I do not know if this could have something to do with the current JURI not parsing properly? This is the only thing I can think of that would be causing this...

I guess my next question is... do you know another method, other than the current() function, that will accomplish what I am trying to do?

Thanks!

Chris

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

守护在此方 2024-12-15 05:25:17

您可以使用模板样式来帮助完成此过程。

您可以复制样式,并更改样式的相关内容 - 但每种样式将使用相同的“模板”。

我已经尝试了一下,我认为它可能非常接近您想要做的事情 - 除非您想要第二个模板完全独立的外观,在这种情况下,使用 2 个模板可能是“最佳选择” '。

不过,我建议您研究一下模板样式 - 本质上,您可以拥有任意数量的模板“样式”,但一切都基于该“模板”,只是样式发生了变化。您可以进入菜单项并从模板下拉列表中选择该样式。我希望这有助于理解,因为这听起来正是您正在寻找的内容。

另外,我建议您先升级到 1.7,然后再进行进一步的开发。既是出于安全原因,也是为了确保您的模板项目能够在 1.7 中顺利运行(它们非常相似,但我有一些模板不喜欢从 1.6 跳转到 1.7)。

*编辑:这里有一些关于它的信息:Joomla 样式

You can use template Styles to help in this process.

You can duplicate styles, and change things about the style - but each style will use the same 'template'.

I've played around with it a bit and I think it's probably pretty close to exactly what you're looking to do - unless you wanted a completely separate look for the 2nd template in which case using 2 templates will probably be the 'best bet'.

I'd recommend looking into template styles though - essentially you could have as many 'styles' of the template as you want, but everything is based off of that one 'template', it's only the style that's changing. You can go into your menu items and select that style from the dropdown for templates. I hope that helps to make sense, because it sounds like exactly what you're looking for.

Also, I'd recommend following the upgrade to 1.7 before you get too far along in development. Both for security reasons, and to make sure your template items work smoothly with 1.7 (they're pretty similar, but I've had some templates that didn't enjoy the jump from 1.6 -> 1.7).

*edit: here is a little information on it: Joomla Styles

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文