简体   繁体   English

cakephp和thickbox-如何使图像成为打开thickbox的链接

[英]cakephp and thickbox - how do I make an image a link which opens a thickbox

Hi there I'm trying to use a thickbox http://jquery.com/demo/thickbox/ to open up a form on my homepage. 嗨,我正在尝试使用一个thickbox http://jquery.com/demo/thickbox/在我的主页上打开一个表单。

I want the link which opens the thickbox to be an image but being a bit new to all this I'm struggling to figure out exactly how to do this. 我希望打开thickbox的链接是一幅图像,但对于所有这些我都在努力寻找确切的实现方法。 the instructions say: 指令说:

In the href attribute of the link add the following anchor: 在链接的href属性中添加以下锚点:

#TB_inline

In the href attribute after the #TB_inline add the following query string on to the anchor: 在#TB_inline之后的href属性中,将以下查询字符串添加到锚点:

?height=300&width=300&inlineId=myOnPageContent

I've got this 我有这个

echo $this->Html->image('123.jpg', array('alt'=>'Create a page', 'url'=>'#TB_inline?height=155&width=300&inlineId=hiddenContent&modal=true', 'class' => 'thickbox'));

What do I need to put to make image.jpg be a link which opens up a thickbox who's contents is the function Campaigns::thickbox?? 我需要做些什么来使image.jpg成为打开一个厚框的链接,该厚框的内容是Campaigns :: thickbox功能?

Thanks :) 谢谢 :)

To create the link itself: 要创建链接本身:

<a href="#TB_inline?height=155&width=300&inlineId=hiddenContent&modal=true" class="thickbox">
  <?php echo $this->Html->image('123.jpg', array('alt'=>'Create a page')); ?>
</a>

Then somewhere on your page you need to have a div with the content for that link to display: 然后,在页面上的某处,您需要有一个div,其中包含要显示的链接内容:

<div id="hiddenContent">
  <p>
    <?php echo Campaigns::thickbox(); ?>
  </p>
</div>

I am assuming here that Campaigns::thickbox() is a static method that returns whatever content you want to display. 我在这里假设Campaigns :: thickbox()是一个静态方法,该方法返回要显示的任何内容。

I would also add some css to the hiddenContent id to make it hidden at first: 我还将添加一些css到hiddenContent id以使其首先隐藏:

#hiddenContent { display: none; }

Edit: I edited the image display code. 编辑:我编辑了图像显示代码。 Remember this: In order to make an image a link, it takes two html tags, an outer "a" tag that holds the link information, and an inner "img" tag that holds the image information. 请记住以下几点:为了使图像成为链接,它需要两个html标签,一个外部的“ a”标签用于保存链接信息,而一个内部的“ img”标签用于保存图像信息。 In this case you are using php to get the img tag information from CakePHP. 在这种情况下,您将使用php从CakePHP获取img标签信息。

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

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