开发者

How can I have use a single post template to display content in both fancybox and as a standalone single post?

Here is what I am trying to accomplish:

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

When a开发者_Python百科 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜