如何使用单个帖子模板在 fancybox 中显示内容并作为独立的单个帖子显示内容?

发布于 2024-10-17 03:55:04 字数 927 浏览 4 评论 0原文

这就是我想要实现的目标:

我有一个缩略图库;每个缩略图链接到一个帖子。

当用户点击缩略图时,永久链接的帖子将在 Fancy Box iframe 中打开。

该 iframe 的内容是单个帖子模板包含的内容,因为它仅使用简单的、WP 生成的永久链接。因此,目前模板不包含页眉、侧边栏、页脚 - 它只包含足够的标记,可以在 Fancy Box iframe 中很好地设计样式。

在尝试实现 Add-to-Any 小部件之前,这是一个很好的解决方案。当从 iframe 中单击此按钮时,它会获取单个帖子的 URL。

这是一个问题,因为如果用户直接进入从 Add-to-Any 链接的模板,他们将被带到一个没有页眉、页脚和侧边栏的页面 - 如果您直接访问帖子,您可能会想要有!

我认为,我的解决方案是以下之一:

1)以某种方式修改“添加到任意”URL,以便用户重定向到图库页面,但以某种方式在加载时强制打开 iframe(使用“伪造”) ' 使用 jQuery 的点击事件?) - 本质上,接收链接的人将准确地看到链接他们的用户所看到的内容,

或者

2)以某种方式将“添加到任何 URL”或永久链接修改为稍微不同的文件路径,以便我可以使用模板提示,并在直接访问帖子时有一个特殊的模板。

其中哪一个听起来是最无痛的选择?现在我有点不确定如何实施其中任何一个。我认为选项#1 是理想的,但我不确定 - 这就是我来这里的原因,我需要一些反馈来确保我以相对理智的方式处理这个问题。我该如何去做#1呢?

很抱歉,对于这个,我无法提供有效的演示,所以我希望这个描述是足够的。如果我不清楚,请提问。如果可以的话,我会考虑举一个例子;大多数情况下,我只需要确认演示由谁托管。

Here is what I am trying to accomplish:

I have a gallery of thumbnails; each thumbnail links to a single post.

When a user clicks on a thumbnail, the permalink'd post opens in a Fancy Box iframe.

The content for that iframe is whatever the single post template contains because it is only using the simple, WP-generated permalink. So, at the moment the template contains no header, sidebar, footer - it just contains enough markup that it could be styled nicely in the Fancy Box iframe.

This was a nice solution until trying to implement the Add-to-Any widget. When this button is clicked from within the iframe, it takes the single post's URL.

This is a problem because if the user goes directly to the template as linked from Add-to-Any, they are taken to a page without the header, footer, and sidebar - which if you are visiting a post directly, you would want to have!

My solution, I think, is one of the following:

1) Somehow modify the Add-to-Any URL so that the user is redirected to the gallery page but in a way that force-opens the iframe on load (with a 'faked' click event using jQuery?) - essentially, then the person who received the link will see exactly what the user linking them saw,

or

2) Somehow modify the Add-to-Any URL or permalink to a slightly different file path, so that I can use template hints and have a special template for when the post is accessed directly.

Which of these sounds like the most painless option? Right now I'm a little unsure as to how to go about implementing either of them. I think that option #1 is ideal, but I'm not sure - and that's why I'm here, I need some feedback to make sure I'm going about this in a relatively sane way. How would I go about #1 at all?

I'm sorry, but for this one I am unable to provide a working demo and so I hope that this description is adequate. Please, ask questions if I am unclear. I will see about giving an example if I can; mostly I just need to confirm with who the demo is hosted with.

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

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

发布评论

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

评论(1

自找没趣 2024-10-24 03:55:04

我要做的是修改由初始缩略图库生成的链接。因此,它不仅仅包含单个帖子的网址,还包含另一个变量。因此,例如:

http://mydomain.com/category/single-post/? lightbox=true

然后,在 single.php 模板文件中,您可以检查 url 字符串以查看它是否包含特定的“添加”。如果没有,那么您应该包含普通单个帖子将使用的普通页眉/页脚/侧边栏恶作剧。

What I'd do is modify the link that is generated by the initial gallery of thumbnails. So, instead of just the single post's url, it would include another variable in it. So, for example:

http://mydomain.com/category/single-post/?lightbox=true

Then, in the single.php template file, you can check the url string to see if it contains that particular 'addition'. If it doesn't, then you should include the normal header/footer/sidebar shenanigans that a normal single post would use.

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